flutter/lib/pages/chat/notify_controller/notify_no_friend_controller.dart
2025-08-27 23:26:29 +08:00

35 lines
1.2 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import 'package:get/get.dart';
import 'package:loopin/IM/im_service.dart';
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart';
class NotifyNoFriendController extends GetxController {
final RxList<V2TimConversation> convList = <V2TimConversation>[].obs;
void updateUnread({required String conversationID}) {
final index = convList.indexWhere((c) => c.conversationID == conversationID);
if (index != -1) {
final conv = convList[index];
convList[index] = conv..unreadCount = 0;
} else {
logger.e('会话不存在,更新未读失败');
}
}
void updateLastMsg({required V2TimConversation conversation}) {
final index = convList.indexWhere((c) => c.conversationID == conversation.conversationID);
if (index != -1) {
convList[index] = conversation;
convList.refresh();
// convList.value = List.from(convList)..[index] = conversation;
} else {
// 根据会话id查询会话检测是否存在
logger.e('会话不存在,更新会话失败');
// 如果存在说明在后面的分页中先insert进去 convlist做去重处理
}
}
void insertData({required List<V2TimConversation> conversationList}) {
convList.insertAll(0, conversationList);
}
}