Skip to content

Commit

Permalink
update thumbnail download try times
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangzhiguo1992 authored and iheron committed Jan 30, 2023
1 parent 68096f2 commit 8670a6d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/common/chat/chat.dart
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ class ChatCommon with Tag {
return message;
}

Future<MessageSchema?> tryDownloadIpfsThumbnail(MessageSchema message) async {
Future<MessageSchema?> tryDownloadIpfsThumbnail(MessageSchema message, {int tryTimes = 0}) async {
String? ipfsHash = MessageOptions.getIpfsThumbnailHash(message.options);
if (ipfsHash == null || ipfsHash.isEmpty) {
logger.e("$TAG - tryDownloadIpfsThumbnail - ipfsHash is empty - message:$message");
Expand Down Expand Up @@ -835,7 +835,12 @@ class ChatCommon with Tag {
message.options = MessageOptions.setIpfsThumbnailState(message.options, MessageOptions.ipfsThumbnailStateNo);
await MessageStorage.instance.updateOptions(message.msgId, message.options);
_onUpdateSink.add(message);
_onIpfsUpOrDownload(message.msgId, "THUMBNAIL", false, false); // await
_onIpfsUpOrDownload(message.msgId, "THUMBNAIL", false, false).then((value) {
if (tryTimes >= 2) return; // try 3 times
Future.delayed(Duration(seconds: 3)).then((value) {
tryDownloadIpfsThumbnail(message, tryTimes: tryTimes + 1);
});
}); // await
},
);
return message;
Expand Down

0 comments on commit 8670a6d

Please sign in to comment.