Merge branch 'feature' of gitea.haiyihy.com:hy/chatapp3-flutter into feature
This commit is contained in:
commit
8096ca6acc
@ -1046,6 +1046,22 @@ class RealTimeMessagingManager extends ChangeNotifier {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final context = navigatorKey.currentState?.context;
|
||||||
|
if (context == null || !context.mounted) {
|
||||||
|
_cpInviteLog(
|
||||||
|
'skip local gift waiting reason=no_context '
|
||||||
|
'receiverId=$receiverId relationType=$normalizedRelationType',
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!_canAutoShowCpInviteDialog(context)) {
|
||||||
|
_cpInviteLog(
|
||||||
|
'skip local gift waiting reason=not_in_visible_voice_room '
|
||||||
|
'receiverId=$receiverId relationType=$normalizedRelationType',
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
final applyId = await _latestCpGiftApplyId(
|
final applyId = await _latestCpGiftApplyId(
|
||||||
receiverId,
|
receiverId,
|
||||||
relationType: normalizedRelationType,
|
relationType: normalizedRelationType,
|
||||||
@ -1060,6 +1076,13 @@ class RealTimeMessagingManager extends ChangeNotifier {
|
|||||||
if (!await _isCpInviteApplyWaitingForAutoPopup(applyId)) {
|
if (!await _isCpInviteApplyWaitingForAutoPopup(applyId)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!context.mounted || !_canAutoShowCpInviteDialog(context)) {
|
||||||
|
_cpInviteLog(
|
||||||
|
'skip local gift waiting reason=voice_room_hidden_after_status '
|
||||||
|
'applyId=$applyId receiverId=$receiverId',
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!_shownCpInviteMessageKeys.add(applyId)) {
|
if (!_shownCpInviteMessageKeys.add(applyId)) {
|
||||||
_cpInviteLog(
|
_cpInviteLog(
|
||||||
'skip duplicated local gift waiting applyId=$applyId '
|
'skip duplicated local gift waiting applyId=$applyId '
|
||||||
@ -1068,15 +1091,6 @@ class RealTimeMessagingManager extends ChangeNotifier {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final context = navigatorKey.currentState?.context;
|
|
||||||
if (context == null || !context.mounted) {
|
|
||||||
_cpInviteLog(
|
|
||||||
'skip local gift waiting reason=no_context '
|
|
||||||
'applyId=$applyId receiverId=$receiverId',
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final currentName = _cpInviteDisplayName(
|
final currentName = _cpInviteDisplayName(
|
||||||
nickname: currentProfile.userNickname,
|
nickname: currentProfile.userNickname,
|
||||||
account: currentProfile.account,
|
account: currentProfile.account,
|
||||||
@ -1161,16 +1175,6 @@ class RealTimeMessagingManager extends ChangeNotifier {
|
|||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!await _isCpInviteApplyWaitingForAutoPopup(applyId)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final messageKey = applyId.isNotEmpty ? applyId : message?.msgID ?? "";
|
|
||||||
if (messageKey.isNotEmpty && !_shownCpInviteMessageKeys.add(messageKey)) {
|
|
||||||
_cpInviteLog(
|
|
||||||
'skip duplicated CP_BUILD applyId=$applyId msgId=${message?.msgID}',
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final context = navigatorKey.currentState?.context;
|
final context = navigatorKey.currentState?.context;
|
||||||
final currentProfile = AccountStorage().getCurrentUser()?.userProfile;
|
final currentProfile = AccountStorage().getCurrentUser()?.userProfile;
|
||||||
if (context == null || currentProfile == null) {
|
if (context == null || currentProfile == null) {
|
||||||
@ -1183,6 +1187,29 @@ class RealTimeMessagingManager extends ChangeNotifier {
|
|||||||
_cpInviteLog('skip CP_BUILD reason=context_unmounted applyId=$applyId');
|
_cpInviteLog('skip CP_BUILD reason=context_unmounted applyId=$applyId');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!_canAutoShowCpInviteDialog(context)) {
|
||||||
|
_cpInviteLog(
|
||||||
|
'skip CP_BUILD reason=not_in_visible_voice_room applyId=$applyId',
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!await _isCpInviteApplyWaitingForAutoPopup(applyId)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!context.mounted || !_canAutoShowCpInviteDialog(context)) {
|
||||||
|
_cpInviteLog(
|
||||||
|
'skip CP_BUILD reason=voice_room_hidden_after_status '
|
||||||
|
'applyId=$applyId',
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final messageKey = applyId.isNotEmpty ? applyId : message?.msgID ?? "";
|
||||||
|
if (messageKey.isNotEmpty && !_shownCpInviteMessageKeys.add(messageKey)) {
|
||||||
|
_cpInviteLog(
|
||||||
|
'skip duplicated CP_BUILD applyId=$applyId msgId=${message?.msgID}',
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (_cpInviteTargetsCurrentAsSenderAndReceiver(
|
if (_cpInviteTargetsCurrentAsSenderAndReceiver(
|
||||||
invite,
|
invite,
|
||||||
currentProfile,
|
currentProfile,
|
||||||
@ -1507,6 +1534,13 @@ class RealTimeMessagingManager extends ChangeNotifier {
|
|||||||
required _CpInviteProcessResult result,
|
required _CpInviteProcessResult result,
|
||||||
required String relationType,
|
required String relationType,
|
||||||
}) async {
|
}) async {
|
||||||
|
if (!_canAutoShowCpInviteDialog(context)) {
|
||||||
|
_cpInviteLog(
|
||||||
|
'skip CP invite result dialog reason=not_in_visible_voice_room '
|
||||||
|
'result=${result.name} relationType=$relationType',
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
final isSender = _cpInviteSenderMatchesCurrent(
|
final isSender = _cpInviteSenderMatchesCurrent(
|
||||||
invite,
|
invite,
|
||||||
currentProfile,
|
currentProfile,
|
||||||
@ -1890,6 +1924,29 @@ class RealTimeMessagingManager extends ChangeNotifier {
|
|||||||
.trim();
|
.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool _canAutoShowCpInviteDialog(BuildContext context) {
|
||||||
|
if (!context.mounted) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
final rtcProvider = Provider.of<RealTimeCommunicationManager>(
|
||||||
|
context,
|
||||||
|
listen: false,
|
||||||
|
);
|
||||||
|
final roomProfile = rtcProvider.currenRoom?.roomProfile?.roomProfile;
|
||||||
|
final roomId = roomProfile?.id?.trim() ?? "";
|
||||||
|
final groupId = roomProfile?.roomAccount?.trim() ?? "";
|
||||||
|
return rtcProvider.isVoiceRoomRouteVisible &&
|
||||||
|
(roomId.isNotEmpty || groupId.isNotEmpty);
|
||||||
|
} catch (error) {
|
||||||
|
_cpInviteLog(
|
||||||
|
'skip auto CP invite dialog reason=voice_room_state_unavailable '
|
||||||
|
'error=$error',
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SocialChatUserProfile _cpInviteInviterProfile(
|
SocialChatUserProfile _cpInviteInviterProfile(
|
||||||
SCSystemInvitMessageRes invite,
|
SCSystemInvitMessageRes invite,
|
||||||
) {
|
) {
|
||||||
@ -3112,6 +3169,10 @@ class RealTimeMessagingManager extends ChangeNotifier {
|
|||||||
msg.noticeAction != "RELATION_ESTABLISHED") {
|
msg.noticeAction != "RELATION_ESTABLISHED") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
final currentContext = context;
|
||||||
|
if (currentContext == null || !_canAutoShowCpInviteDialog(currentContext)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
final currentProfile = AccountStorage().getCurrentUser()?.userProfile;
|
final currentProfile = AccountStorage().getCurrentUser()?.userProfile;
|
||||||
if (currentProfile == null) {
|
if (currentProfile == null) {
|
||||||
return;
|
return;
|
||||||
@ -3175,18 +3236,19 @@ class RealTimeMessagingManager extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _showCpInviteRejectedDialog(String relationType, {String? dedupKey}) {
|
void _showCpInviteRejectedDialog(String relationType, {String? dedupKey}) {
|
||||||
|
final context = navigatorKey.currentState?.context;
|
||||||
|
if (context == null || !_canAutoShowCpInviteDialog(context)) {
|
||||||
|
_cpInviteLog(
|
||||||
|
'skip rejected dialog reason=not_in_visible_voice_room '
|
||||||
|
'relationType=$relationType',
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
final key = dedupKey?.trim() ?? "";
|
final key = dedupKey?.trim() ?? "";
|
||||||
if (key.isNotEmpty && !_shownCpInviteRejectedDialogKeys.add(key)) {
|
if (key.isNotEmpty && !_shownCpInviteRejectedDialogKeys.add(key)) {
|
||||||
_cpInviteLog('skip duplicated rejected dialog key=$key');
|
_cpInviteLog('skip duplicated rejected dialog key=$key');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final context = navigatorKey.currentState?.context;
|
|
||||||
if (context == null) {
|
|
||||||
_cpInviteLog(
|
|
||||||
'skip rejected dialog reason=no_context relationType=$relationType',
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final localizations = SCAppLocalizations.of(context);
|
final localizations = SCAppLocalizations.of(context);
|
||||||
SmartDialog.show(
|
SmartDialog.show(
|
||||||
tag: "showConfirmDialog",
|
tag: "showConfirmDialog",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user