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