WuKongIM / WuKongIMFlutterSDK

Flutter sdk for WuKongIM
Apache License 2.0
32 stars 25 forks source link

同步离线消息时 刷新消息 返回的内容为空 #8

Closed unicornB closed 11 months ago

unicornB commented 1 year ago
WKIM.shared.conversationManager.addOnRefreshMsgListener('chat_conversation',
        (msg, isEnd) async {
      log("监听会话消息");
      bool isAdd = true;
      for (var i = 0; i < msgList.value.length; i++) {
        if (msgList.value[i].msg.channelID == msg.channelID &&
            msgList.value[i].msg.channelType == msg.channelType) {
          msgList.value[i].msg = msg;
          log("wkMsg clientMsgNo is ${msg.clientMsgNo}");
          WKMsg? wkMsg = await msg.getWkMsg()//同步离线消息时wkMsg总是为空

          if (wkMsg != null) {
            msgList.value[i].lastContent = wkMsg.messageContent!.displayText();
          } else {
            log("wkMsg is null");
          }
          isAdd = false;
          break;
        }
      }

List list = await WKIM.shared.conversationManager.getAll(); 同步后使用这个函数正常 证明同步离线数据没问题 目前解决方式是isEnd去调用这个函数 还是希望刷新是直接修改列表

No8blackball commented 1 year ago

更新sdk到1.0.9后参考 https://github.com/WuKongIM/WuKongIMFlutterSDK/blob/master/example/lib/chat.dart