addDownloadMessageToQueue static method

void addDownloadMessageToQueue({
  1. required DownloadMessageQueueData data,
  2. bool? isClick,
})

Implementation

static void addDownloadMessageToQueue({
  required DownloadMessageQueueData data,
  bool? isClick,
}) {
  if (TencentCloudChat.instance.dataInstance.basic.userConfig.autoDownloadMultimediaMessage == true || isClick == true || data.isSnapshot == true) {
    if (downloadQueue.containsKey(data.convID)) {
      if (downloadQueue[data.convID] != null) {
        int idx = downloadQueue[data.convID]!.indexWhere((element) => element.getUniqueueKey() == data.getUniqueueKey());
        if (idx > -1) {
          console("${data.getUniqueueKey()} is already add to the download queue");
          return;
        }
      }
    } else {
      downloadQueue[data.convID] = [];
    }
    int curDownloadingIdx = currentDownloadingList.indexWhere((ele) => ele.getUniqueueKey() == data.getUniqueueKey());
    if (curDownloadingIdx > -1) {
      console("${data.msgID} is downloading");
      return;
    }
    downloadQueue[data.convID]!.add(data);

    console("add ${data.msgID} to the download queue. message type ${data.messageType}");
  } else {
    console("add message to download queue failed . ");
  }
}