fix(mobile-next): 把加载、失败、断网接到真实 SDK 与目录请求

会话列表、通讯录、好友申请、添加同事页覆盖 CompanyLoadingView/CompanyFailView;
主页断网横幅跟随 IMSdkStatus.connectionFailed。不伪造状态。

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
编码工程师
2026-08-20 02:52:24 +08:00
co-authored by Cursor multica-agent
parent 092f513708
commit 2b2c2d28a4
9 changed files with 432 additions and 186 deletions
@@ -11,6 +11,8 @@ class FriendRequestsLogic extends GetxController {
final imLogic = Get.find<IMController>();
final homeLogic = Get.find<HomeLogic>();
final applicationList = <FriendApplicationInfo>[].obs;
final loading = true.obs;
final loadFailed = false.obs;
late StreamSubscription faSub;
@override
@@ -27,6 +29,8 @@ class FriendRequestsLogic extends GetxController {
super.onReady();
}
void retry() => _getFriendRequestsList();
@override
void onClose() {
faSub.cancel();
@@ -35,43 +39,56 @@ class FriendRequestsLogic extends GetxController {
}
void _getFriendRequestsList() async {
final list = await Future.wait([
OpenIM.iMManager.friendshipManager.getFriendApplicationListAsRecipient(),
OpenIM.iMManager.friendshipManager.getFriendApplicationListAsApplicant(),
]);
loading.value = true;
loadFailed.value = false;
try {
final list = await Future.wait([
OpenIM.iMManager.friendshipManager
.getFriendApplicationListAsRecipient(),
OpenIM.iMManager.friendshipManager
.getFriendApplicationListAsApplicant(),
]);
final allList = <FriendApplicationInfo>[];
allList
..addAll(list[0])
..addAll(list[1]);
final allList = <FriendApplicationInfo>[];
allList
..addAll(list[0])
..addAll(list[1]);
allList.sort((a, b) {
if (a.createTime! > b.createTime!) {
return -1;
} else if (a.createTime! < b.createTime!) {
return 1;
}
return 0;
});
allList.sort((a, b) {
if (a.createTime! > b.createTime!) {
return -1;
} else if (a.createTime! < b.createTime!) {
return 1;
}
return 0;
});
var haveReadList = DataSp.getHaveReadUnHandleFriendApplication();
haveReadList ??= <String>[];
for (var e in list[0]) {
var id = IMUtils.buildFriendApplicationID(e);
if (!haveReadList.contains(id)) {
haveReadList.add(id);
var haveReadList = DataSp.getHaveReadUnHandleFriendApplication();
haveReadList ??= <String>[];
for (var e in list[0]) {
var id = IMUtils.buildFriendApplicationID(e);
if (!haveReadList.contains(id)) {
haveReadList.add(id);
}
}
DataSp.putHaveReadUnHandleFriendApplication(haveReadList);
applicationList.assignAll(allList);
} catch (e, s) {
Logger.print('friend requests e: $e $s');
loadFailed.value = true;
} finally {
loading.value = false;
}
DataSp.putHaveReadUnHandleFriendApplication(haveReadList);
applicationList.assignAll(allList);
}
bool isISendRequest(FriendApplicationInfo info) => info.fromUserID == OpenIM.iMManager.userID;
bool isISendRequest(FriendApplicationInfo info) =>
info.fromUserID == OpenIM.iMManager.userID;
void acceptFriendApplication(FriendApplicationInfo info) async {
try {
await LoadingView.singleton.wrap(
asyncFunction: () => OpenIM.iMManager.friendshipManager.acceptFriendApplication(userID: info.fromUserID!),
asyncFunction: () => OpenIM.iMManager.friendshipManager
.acceptFriendApplication(userID: info.fromUserID!),
);
IMViews.showToast(StrRes.addSuccessfully);
_getFriendRequestsList();
@@ -83,7 +100,8 @@ class FriendRequestsLogic extends GetxController {
void refuseFriendApplication(FriendApplicationInfo info) async {
try {
await LoadingView.singleton.wrap(
asyncFunction: () => OpenIM.iMManager.friendshipManager.refuseFriendApplication(userID: info.fromUserID!),
asyncFunction: () => OpenIM.iMManager.friendshipManager
.refuseFriendApplication(userID: info.fromUserID!),
);
IMViews.showToast(StrRes.rejectSuccessfully);
_getFriendRequestsList();