修复消息
This commit is contained in:
parent
c3ad3be817
commit
ad0fd72180
@ -146,6 +146,7 @@ class _SCMessageChatPageState extends State<SCMessageChatPage> {
|
||||
SocialChatUserProfile? friend;
|
||||
SCVipResourceRes? _selfVipChatBubble;
|
||||
bool _isSelfVipChatBubbleLoading = false;
|
||||
final Map<String, _CpInviteMessageState> _localCpInviteStates = {};
|
||||
|
||||
///是否显示发送按钮
|
||||
bool showSend = false;
|
||||
@ -602,6 +603,8 @@ class _SCMessageChatPageState extends State<SCMessageChatPage> {
|
||||
currentConversationMessageList[i].sender == "administrator",
|
||||
friend: friend,
|
||||
currentConversationMessageList: currentConversationMessageList,
|
||||
localCpInviteStates: _localCpInviteStates,
|
||||
onCpInviteStateChanged: _setLocalCpInviteState,
|
||||
updateCall: () {
|
||||
setState(() {});
|
||||
},
|
||||
@ -614,6 +617,17 @@ class _SCMessageChatPageState extends State<SCMessageChatPage> {
|
||||
);
|
||||
}
|
||||
|
||||
void _setLocalCpInviteState(String applyId, _CpInviteMessageState state) {
|
||||
final normalizedApplyId = applyId.trim();
|
||||
if (normalizedApplyId.isEmpty) {
|
||||
return;
|
||||
}
|
||||
_localCpInviteStates[normalizedApplyId] = state;
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
|
||||
List<V2TimMessage> _messagesInDisplayOrder(List<V2TimMessage> messages) {
|
||||
final indexedMessages = messages.asMap().entries.toList();
|
||||
indexedMessages.sort((left, right) {
|
||||
@ -1177,6 +1191,9 @@ class _MessageItem extends StatelessWidget {
|
||||
final SocialChatUserProfile? friend;
|
||||
bool isSystem = false;
|
||||
List<V2TimMessage> currentConversationMessageList = [];
|
||||
final Map<String, _CpInviteMessageState> localCpInviteStates;
|
||||
final void Function(String applyId, _CpInviteMessageState state)?
|
||||
onCpInviteStateChanged;
|
||||
Function updateCall;
|
||||
|
||||
///上一条
|
||||
@ -1190,6 +1207,8 @@ class _MessageItem extends StatelessWidget {
|
||||
// this.userProfile,
|
||||
this.isSystem = false,
|
||||
required this.currentConversationMessageList,
|
||||
this.localCpInviteStates = const {},
|
||||
this.onCpInviteStateChanged,
|
||||
this.friend,
|
||||
required this.updateCall,
|
||||
});
|
||||
@ -1526,7 +1545,7 @@ class _MessageItem extends StatelessWidget {
|
||||
if (data == null || !_isCpInvitePayload(data)) {
|
||||
return null;
|
||||
}
|
||||
if (_cpInviteStateFromData(data) != _CpInviteMessageState.accepted) {
|
||||
if (_cpInviteStateForMessage(data) != _CpInviteMessageState.accepted) {
|
||||
return null;
|
||||
}
|
||||
final cpInvite = _cpInviteFromMessageData(data);
|
||||
@ -1667,7 +1686,7 @@ class _MessageItem extends StatelessWidget {
|
||||
if (data == null || !_isCpInvitePayload(data)) {
|
||||
return null;
|
||||
}
|
||||
final state = _cpInviteStateFromData(data);
|
||||
final state = _cpInviteStateForMessage(data);
|
||||
if (state == _CpInviteMessageState.pending) {
|
||||
return null;
|
||||
}
|
||||
@ -1922,6 +1941,10 @@ class _MessageItem extends StatelessWidget {
|
||||
return;
|
||||
}
|
||||
SmartDialog.dismiss(tag: RoomCpInviteDialog.dialogTag);
|
||||
onCpInviteStateChanged?.call(
|
||||
applyId,
|
||||
agree ? _CpInviteMessageState.accepted : _CpInviteMessageState.rejected,
|
||||
);
|
||||
_cpMessageLog(
|
||||
'process submitted applyId=$applyId agree=$agree '
|
||||
'wait_backend_result=true',
|
||||
@ -2009,6 +2032,10 @@ class _MessageItem extends StatelessWidget {
|
||||
}
|
||||
|
||||
_CpInviteMessageState _cpInviteStateForMessage(Map<String, dynamic> data) {
|
||||
final localState = _localCpInviteStateForData(data);
|
||||
if (localState != null) {
|
||||
return localState;
|
||||
}
|
||||
final explicitState = _cpInviteStateFromConversation(data);
|
||||
if (explicitState != _CpInviteMessageState.pending) {
|
||||
return explicitState;
|
||||
@ -2022,6 +2049,10 @@ class _MessageItem extends StatelessWidget {
|
||||
Map<String, dynamic> currentData,
|
||||
) {
|
||||
final applyId = _cpApplyIdFromData(currentData);
|
||||
final localState = _localCpInviteStateForApplyId(applyId);
|
||||
if (localState != null) {
|
||||
return localState;
|
||||
}
|
||||
final currentState = _cpInviteStateFromData(currentData);
|
||||
if (currentState != _CpInviteMessageState.pending || applyId.isEmpty) {
|
||||
return currentState;
|
||||
@ -2043,6 +2074,18 @@ class _MessageItem extends StatelessWidget {
|
||||
return _CpInviteMessageState.pending;
|
||||
}
|
||||
|
||||
_CpInviteMessageState? _localCpInviteStateForData(Map<String, dynamic> data) {
|
||||
return _localCpInviteStateForApplyId(_cpApplyIdFromData(data));
|
||||
}
|
||||
|
||||
_CpInviteMessageState? _localCpInviteStateForApplyId(String applyId) {
|
||||
final normalizedApplyId = applyId.trim();
|
||||
if (normalizedApplyId.isEmpty) {
|
||||
return null;
|
||||
}
|
||||
return localCpInviteStates[normalizedApplyId];
|
||||
}
|
||||
|
||||
bool _isDuplicateCpInviteMessageForConversation(Map<String, dynamic> data) {
|
||||
final currentKey = _cpInviteMessageDedupKey(data);
|
||||
if (currentKey.isEmpty) {
|
||||
@ -2086,7 +2129,7 @@ class _MessageItem extends StatelessWidget {
|
||||
if (!_isCpInvitePayload(data)) {
|
||||
return "";
|
||||
}
|
||||
final state = _cpInviteStateFromData(data);
|
||||
final state = _cpInviteStateForMessage(data);
|
||||
final applyId = _cpApplyIdFromData(data);
|
||||
if (applyId.isEmpty) {
|
||||
return "";
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user