updateCurrentDownloadMessage static method

void updateCurrentDownloadMessage(
  1. V2TimMessageDownloadProgress progress
)

Implementation

static void updateCurrentDownloadMessage(V2TimMessageDownloadProgress progress) {
  String messageIdentfif = "${progress.msgID}_${progress.type}_${progress.isSnapshot}";

  int idx = currentDownloadingList.indexWhere((ele) => ele.getUniqueueKey() == messageIdentfif);
  if (idx > -1) {
    DownloadMessageQueueData currentProgressData = currentDownloadingList[idx];
    currentProgressData.currentDownloadSize = progress.currentSize;
    currentProgressData.totalSize = progress.totalSize;
    currentProgressData.downloadFinish = progress.isFinish;
    if (progress.isFinish) {
      if (currentProgressData.isSnapshot == true) {
        currentProgressData.snapPath = progress.path;
      } else {
        currentProgressData.path = progress.path;
      }
    }

    for (var i = 0; i < currentDownloadingList.length; i++) {
      console("update download progress ${currentDownloadingList[i].currentDownloadSize} ${currentDownloadingList[i].totalSize}");
    }
    TencentCloudChat.instance.dataInstance.messageData.updateDownloadingMessage(currentDownloadingList);
  }
}