From 352ca150a0e4228909dc0e5a1224793749f45dbe Mon Sep 17 00:00:00 2001 From: zhx Date: Mon, 25 May 2026 18:02:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BC=B9=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ios/Podfile.lock | 54 +++++++-------- lib/services/audio/rtm_manager.dart | 103 +++++++++++++++++++--------- 2 files changed, 97 insertions(+), 60 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 6ebc174..76d05b1 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -346,15 +346,15 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/webview_flutter_wkwebview/darwin" SPEC CHECKSUMS: - app_links: 3dbc685f76b1693c66a6d9dd1e9ab6f73d97dc0a + app_links: 585674be3c6661708e6cd794ab4f39fb9d8356f9 AppAuth: d4f13a8fe0baf391b2108511793e4b479691fb73 AppCheckCore: cc8fd0a3a230ddd401f326489c99990b013f0c4f - audioplayers_darwin: 835ced6edd4c9fc8ebb0a7cc9e294a91d99917d5 - device_info_plus: 71ffc6ab7634ade6267c7a93088ed7e4f74e5896 + audioplayers_darwin: f15e209a3e856d1a7edcf98dc029f484fead2242 + device_info_plus: 97af1d7e84681a90d0693e63169a5d50e0839a0d Firebase: d99ac19b909cd2c548339c2241ecd0d1599ab02e - firebase_auth: 50af8366c87bb88c80ebeae62eb60189c7246b9b - firebase_core: 995454a784ff288be5689b796deb9e9fa3601818 - firebase_crashlytics: 30dcd6dfd2fe895c0848af46722a4227346c19aa + firebase_auth: 5342db41af2ba5ed32a6177d9e326eecbebda912 + firebase_core: 99a37263b3c27536063a7b601d9e2a49400a433c + firebase_crashlytics: 986773c0c7ea4c3f5a4ead141b58522fcd9dfdb1 FirebaseAppCheckInterop: 06fe5a3799278ae4667e6c432edd86b1030fa3df FirebaseAuth: a6575e5fbf46b046c58dc211a28a5fbdd8d4c83b FirebaseAuthInterop: 7087d7a4ee4bc4de019b2d0c240974ed5d89e2fd @@ -366,47 +366,47 @@ SPEC CHECKSUMS: FirebaseRemoteConfigInterop: 1c6135e8a094cc6368949f5faeeca7ee8948b8aa FirebaseSessions: b9a92c1c51bbb81e78fc3142cda6d925d700f8e7 Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467 - flutter_image_compress_common: 1697a328fd72bfb335507c6bca1a65fa5ad87df1 - fluttertoast: 2c67e14dce98bbdb200df9e1acf610d7a6264ea1 - google_sign_in_ios: b48bb9af78576358a168361173155596c845f0b9 + flutter_image_compress_common: ec1d45c362c9d30a3f6a0426c297f47c52007e3e + fluttertoast: 21eecd6935e7064cc1fcb733a4c5a428f3f24f0f + google_sign_in_ios: 7411fab6948df90490dc4620ecbcabdc3ca04017 GoogleDataTransport: aae35b7ea0c09004c3797d53c8c41f66f219d6a7 GoogleSignIn: ce8c89bb9b37fb624b92e7514cc67335d1e277e4 GoogleUtilities: 00c88b9a86066ef77f0da2fab05f65d7768ed8e1 GTMAppAuth: f69bd07d68cd3b766125f7e072c45d7340dea0de GTMSessionFetcher: 5aea5ba6bd522a239e236100971f10cb71b96ab6 HydraAsync: 8d589bd725b0224f899afafc9a396327405f8063 - image_cropper: 655b3ba703c9e15e3111e79151624d6154288774 - image_picker_ios: e0ece4aa2a75771a7de3fa735d26d90817041326 - in_app_purchase_storekit: 22cca7d08eebca9babdf4d07d0baccb73325d3c8 + image_cropper: a3291c624a953049bc6a02e1f8c8ceb162a24b25 + image_picker_ios: 4f2f91b01abdb52842a8e277617df877e40f905b + in_app_purchase_storekit: 2342c0a5da86593124d08dd13d920f39a52b273a libpag: 98742fad4b3ac2a2ee31e383d2483495fb9a5fb4 libwebp: 02b23773aedb6ff1fd38cec7a77b81414c6842a8 Mantle: c5aa8794a29a022dfbbfc9799af95f477a69b62d nanopb: fad817b59e0457d11a5dfbde799381cd727c1275 - on_audio_query_ios: 28a780e2d0d85d92d500ba6e12c6c8167022b2fa - package_info_plus: af8e2ca6888548050f16fa2f1938db7b5a5df499 - pag: f01aa9017ab0e04a83ba4a20d6070a50f0ac9da8 - permission_handler_apple: 4ed2196e43d0651e8ff7ca3483a069d469701f2d + on_audio_query_ios: e5afb0d4b42cfa3e8762d8ec1953540cb4f02100 + package_info_plus: c0502532a26c7662a62a356cebe2692ec5fe4ec4 + pag: ff30ba5e4be59380a5ddac6b183905729be15a3c + permission_handler_apple: 9878588469a2b0d0fc1e048d9f43605f92e6cec2 PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47 PromisesSwift: 9d77319bbe72ebf6d872900551f7eeba9bce2851 RecaptchaInterop: 11e0b637842dfb48308d242afc3f448062325aba SDWebImage: e9fc87c1aab89a8ab1bbd74eba378c6f53be8abf SDWebImageWebPCoder: 0e06e365080397465cc73a7a9b472d8a3bd0f377 - shared_preferences_foundation: 7036424c3d8ec98dfe75ff1667cb0cd531ec82bb - sign_in_with_apple: c5dcc141574c8c54d5ac99dd2163c0c72ad22418 - sqflite_darwin: 20b2a3a3b70e43edae938624ce550a3cbf66a3d0 + shared_preferences_foundation: 5086985c1d43c5ba4d5e69a4e8083a389e2909e6 + sign_in_with_apple: f3bf75217ea4c2c8b91823f225d70230119b8440 + sqflite_darwin: 5a7236e3b501866c1c9befc6771dfd73ffb8702d SwiftyBeaver: 84069991dd5dca07d7069100985badaca7f0ce82 - tancent_vap: fa8ad93814a9f950514a7074c662d2c937084c68 - tencent_cloud_chat_sdk: 55e5fffe20f6b7937a26a674ccccb639563a9790 - tencent_rtc_sdk: f77558b6b436a149d378557c2a837f73c09061bc + tancent_vap: eceaaf095167d102727cf799c75891057834c311 + tencent_cloud_chat_sdk: 546bb906bbe585814e3d2d33afdb91f09c0eac44 + tencent_rtc_sdk: 1ca5201f7bddc691a3a95486325ad6dc792a273d TOCropViewController: edfd4f25713d56905ad1e0b9f5be3fbe0f59c863 TXCustomBeautyProcesserPlugin: 099393b941cb40eda12b3a80bf6c0319957b1cfd TXIMSDK_Plus_iOS_XCFramework: 5d1933192fb3b7ef2fe933f1623de4a0486a7fe2 TXLiteAVSDK_Professional: e792e6084a208ecef6196c5f28237ad8078b4d7c - url_launcher_ios: 7a95fa5b60cc718a708b8f2966718e93db0cef1b - video_player_avfoundation: 3453f792138786248960ca029747fcd9f318ef52 - video_thumbnail: b637e0ad5f588ca9945f6e2c927f73a69a661140 - wakelock_plus: e29112ab3ef0b318e58cfa5c32326458be66b556 - webview_flutter_wkwebview: 8ebf4fded22593026f7dbff1fbff31ea98573c8d + url_launcher_ios: bb13df5870e8c4234ca12609d04010a21be43dfa + video_player_avfoundation: e54d03b3b19f64f2c557354f72ce538387541ba6 + video_thumbnail: c4e2a3c539e247d4de13cd545344fd2d26ffafd1 + wakelock_plus: 76957ab028e12bfa4e66813c99e46637f367fc7e + webview_flutter_wkwebview: 29eb20d43355b48fe7d07113835b9128f84e3af4 PODFILE CHECKSUM: a6f49a93e5f85201a2efdadcd7cf184b0e310894 diff --git a/lib/services/audio/rtm_manager.dart b/lib/services/audio/rtm_manager.dart index bc74275..ca9ca3b 100644 --- a/lib/services/audio/rtm_manager.dart +++ b/lib/services/audio/rtm_manager.dart @@ -788,7 +788,7 @@ class RealTimeMessagingManager extends ChangeNotifier { String? fallbackUserId, }) async { final cpData = _decodeCpSystemMessageData(message); - unawaited(_handleIncomingCpBuildMessage(message)); + unawaited(_handleIncomingCpBuildMessage(message, realtime: true)); final cpPeerUserId = _cpInviteConversationPeerIdFromData( cpData, message: message, @@ -1135,21 +1135,34 @@ class RealTimeMessagingManager extends ChangeNotifier { String receiverId, { required String relationType, }) async { - try { - return await SCAccountRepository().cpRelationshipApplyId( - receiverId, - relationType: relationType, - ); - } catch (error) { - _cpInviteLog( - 'query local gift apply failed receiverId=$receiverId ' - 'relationType=$relationType error=$error', - ); - return null; + Object? lastError; + for (var attempt = 1; attempt <= 4; attempt++) { + try { + final applyId = await SCAccountRepository().cpRelationshipApplyId( + receiverId, + relationType: relationType, + ); + if ((applyId ?? "").trim().isNotEmpty) { + return applyId; + } + } catch (error) { + lastError = error; + } + if (attempt < 4) { + await Future.delayed(Duration(milliseconds: attempt * 250)); + } } + _cpInviteLog( + 'query local gift apply failed receiverId=$receiverId ' + 'relationType=$relationType error=$lastError', + ); + return null; } - Future _handleIncomingCpBuildMessage(V2TimMessage? message) async { + Future _handleIncomingCpBuildMessage( + V2TimMessage? message, { + bool realtime = false, + }) async { final data = _decodeCpSystemMessageData(message); if (data == null) { return; @@ -1193,7 +1206,10 @@ class RealTimeMessagingManager extends ChangeNotifier { ); return; } - if (!await _isCpInviteApplyWaitingForAutoPopup(applyId)) { + if (!await _isCpInviteApplyWaitingForAutoPopup( + applyId, + allowUnknown: realtime, + )) { return; } if (!context.mounted || !_canAutoShowCpInviteDialog(context)) { @@ -1370,27 +1386,48 @@ class RealTimeMessagingManager extends ChangeNotifier { ""; } - Future _isCpInviteApplyWaitingForAutoPopup(String applyId) async { - try { - final status = await SCAccountRepository().cpRelationshipApplyStatus( - applyId, - ); - final normalizedStatus = status?.trim().toUpperCase() ?? ""; - if (normalizedStatus == "WAIT") { - return true; + Future _isCpInviteApplyWaitingForAutoPopup( + String applyId, { + bool allowUnknown = false, + }) async { + Object? lastError; + String? lastStatus; + for (var attempt = 1; attempt <= 4; attempt++) { + try { + final status = await SCAccountRepository().cpRelationshipApplyStatus( + applyId, + ); + final normalizedStatus = status?.trim().toUpperCase() ?? ""; + lastStatus = normalizedStatus; + if (normalizedStatus == "WAIT") { + return true; + } + if (normalizedStatus.isNotEmpty) { + _cpInviteLog( + 'skip CP_BUILD reason=apply_status_not_wait ' + 'applyId=$applyId status=$normalizedStatus', + ); + return false; + } + } catch (error) { + lastError = error; + } + if (attempt < 4) { + await Future.delayed(Duration(milliseconds: attempt * 250)); } - _cpInviteLog( - 'skip CP_BUILD reason=apply_status_not_wait ' - 'applyId=$applyId status=$normalizedStatus', - ); - return false; - } catch (error) { - _cpInviteLog( - 'skip CP_BUILD reason=apply_status_query_failed ' - 'applyId=$applyId error=$error', - ); - return false; } + if (allowUnknown) { + _cpInviteLog( + 'allow realtime CP_BUILD popup after unknown apply status ' + 'applyId=$applyId status=${lastStatus ?? ""} error=$lastError', + ); + return true; + } + _cpInviteLog( + 'skip CP_BUILD reason=apply_status_query_failed ' + 'applyId=$applyId status=${lastStatus ?? ""} error=$lastError', + ); + return false; } bool _handleCpInviteResultMessage(