queryNIMFriendAddApplication method

Future<bool> queryNIMFriendAddApplication({
  1. int offset = 0,
})

分页请求行通知 如果返回false 表示 需要继续请求

Implementation

Future<bool> queryNIMFriendAddApplication({int offset = 0}) {
  return ContactRepo.getAddApplicationList(queryMessageLimit, offset: offset)
      .then((value) {
    if (value.isSuccess) {
      int preLen = friendAddApplications.length;
      _setSysMsgExpire(value.data?.infos);
      _addNewToNIMFriendAddApplications(value.data?.infos ?? []);
      if (value.data != null &&
          value.data!.infos != null &&
          value.data!.infos!.length >= queryMessageLimit) {
        haveMore = true;
      } else {
        haveMore = false;
      }
      if (value.data != null &&
          value.data!.infos != null &&
          value.data!.infos!.isNotEmpty) {
        lastMessage = value.data!.infos!.last;
      }
      notifyListeners();
      int newLen = friendAddApplications.length;
      //1,非首次请求 2,还有更多 3,请求结果不为空 4,合并前后sysMsg长度一样
      //表示此次请求所有的结果都被merge,需要再次请求,所以返回false
      if (offset > 0 &&
          haveMore &&
          (value.data?.infos?.length ?? 0) > 0 &&
          newLen == preLen) {
        return false;
      }
    }
    return true;
  });
}