ChatViewModel constructor

ChatViewModel(
  1. String sessionId,
  2. NIMSessionType sessionType, {
  3. bool showReadAck = true,
})

Implementation

ChatViewModel(this.sessionId, this.sessionType, {this.showReadAck = true}) {
  setChattingAccount();
  setNIMMessageListener();
  if (sessionType == NIMSessionType.p2p) {
    getIt<ContactProvider>().getContact(sessionId).then((value) {
      contactInfo = value;
      chatTitle = value!.getName();
      notifyListeners();
    });
  } else if (sessionType == NIMSessionType.team) {
    ChatMessageRepo.queryTeam(sessionId).then((value) {
      if (value.isSuccess) {
        teamInfo = value.data;
        chatTitle = value.data!.name!;
        notifyListeners();
      }
    });
    getIt<TeamProvider>().queryMemberList(sessionId).then((value) {
      userInfoTeam = value
          ?.where((element) =>
              element.userInfo?.userId !=
              getIt<LoginService>().userInfo?.userId)
          .toList();
      notifyListeners();
    });
  }
  initFetch(null);
}