queryTopAIUser method
void
queryTopAIUser()
Implementation
void queryTopAIUser() {
if (_isQuerying) return; // 如果正在查询,直接返回
_isQuerying = true; // 设置为正在查询
var userList = AIUserManager.instance.getPinDefaultUserList();
_logI('queryTopAIUser -->> ${userList.length}');
_topAIUserList.clear(); // 清空列表
if (userList.isNotEmpty) {
ContactRepo.getUserList([IMKitClient.account()!]).then((value) {
_isQuerying = false; // 查询结束,重置标志位
if (value.isSuccess && value.data != null && value.data!.isNotEmpty) {
var userUnpinArray = AIUserManager.instance.getUnpinAIUserList(
value.data![0],
);
for (var user in userList) {
if (!userUnpinArray.contains(user.accountId) &&
!_topAIUserList.contains(user.accountId)) {
_logI('queryTopAIUser addAIUser-->> ${user.accountId}');
_topAIUserList.add(user);
}
}
}
notifyListeners(); // 仅在查询完成后调用
});
} else {
_isQuerying = false; // 如果没有用户,重置标志位
notifyListeners(); // 直接通知更新
}
}