From e97f0a910f59d43ed80663a5507320caaaa61e6a Mon Sep 17 00:00:00 2001 From: otsmr Date: Tue, 30 Dec 2025 11:21:43 +0100 Subject: [PATCH] fix smaller issues --- .../api/mediafiles/download.service.dart | 38 +++++++++---------- lib/src/services/api/messages.dart | 7 +++- lib/src/services/signal/prekeys.signal.dart | 2 +- .../views/settings/profile/profile.view.dart | 2 +- pubspec.yaml | 2 +- 5 files changed, 25 insertions(+), 26 deletions(-) diff --git a/lib/src/services/api/mediafiles/download.service.dart b/lib/src/services/api/mediafiles/download.service.dart index 12ea9dc..257982e 100644 --- a/lib/src/services/api/mediafiles/download.service.dart +++ b/lib/src/services/api/mediafiles/download.service.dart @@ -224,29 +224,25 @@ Future downloadFileFast( Future requestMediaReupload(String mediaId) async { final messages = await twonlyDB.messagesDao.getMessagesByMediaId(mediaId); - if (messages.length != 1 || messages.first.senderId == null) { - Log.error( - 'Media file has none or more than one sender. That is not possible', - ); - return; - } - await sendCipherText( - messages.first.senderId!, - EncryptedContent( - mediaUpdate: EncryptedContent_MediaUpdate( - type: EncryptedContent_MediaUpdate_Type.DECRYPTION_ERROR, - targetMessageId: messages.first.messageId, + for (final message in messages) { + if (message.openedAt != null) continue; + await sendCipherText( + messages.first.senderId!, + EncryptedContent( + mediaUpdate: EncryptedContent_MediaUpdate( + type: EncryptedContent_MediaUpdate_Type.DECRYPTION_ERROR, + targetMessageId: messages.first.messageId, + ), ), - ), - ); - - await twonlyDB.mediaFilesDao.updateMedia( - mediaId, - const MediaFilesCompanion( - downloadState: Value(DownloadState.reuploadRequested), - ), - ); + ); + await twonlyDB.mediaFilesDao.updateMedia( + mediaId, + const MediaFilesCompanion( + downloadState: Value(DownloadState.reuploadRequested), + ), + ); + } } Future handleEncryptedFile(String mediaId) async { diff --git a/lib/src/services/api/messages.dart b/lib/src/services/api/messages.dart index 6681b73..7955e92 100644 --- a/lib/src/services/api/messages.dart +++ b/lib/src/services/api/messages.dart @@ -50,8 +50,10 @@ Future<(Uint8List, Uint8List?)?> tryToSendCompleteMessage({ } receiptId = receipt.receiptId; - if (!onlyReturnEncryptedData && receipt.ackByServerAt != null) { - Log.error('message already uploaded!'); + if (!onlyReturnEncryptedData && + receipt.ackByServerAt != null && + receipt.markForRetry == null) { + Log.error('Message already uploaded and mark for retry is not set!'); return null; } @@ -141,6 +143,7 @@ Future<(Uint8List, Uint8List?)?> tryToSendCompleteMessage({ ackByServerAt: Value(DateTime.now()), retryCount: Value(receipt.retryCount + 1), lastRetry: Value(DateTime.now()), + markForRetry: const Value(null), ), ); } diff --git a/lib/src/services/signal/prekeys.signal.dart b/lib/src/services/signal/prekeys.signal.dart index f2dcde2..4823eea 100644 --- a/lib/src/services/signal/prekeys.signal.dart +++ b/lib/src/services/signal/prekeys.signal.dart @@ -105,7 +105,7 @@ Future getSignedPreKeyByContactId( } } else { unawaited(requestNewSignedPreKeyForContact(contactId)); - Log.error('Contact $contactId does not have a signed pre key!'); + Log.warn('Contact $contactId does not have a signed pre key!'); } return signedPreKey; } diff --git a/lib/src/views/settings/profile/profile.view.dart b/lib/src/views/settings/profile/profile.view.dart index 0e404a9..61de089 100644 --- a/lib/src/views/settings/profile/profile.view.dart +++ b/lib/src/views/settings/profile/profile.view.dart @@ -51,7 +51,7 @@ class _ProfileViewState extends State { ..avatarCounter = user.avatarCounter + 1; return user; }); - setState(() {}); // gUser has updated + if (mounted) setState(() {}); // gUser has updated } Future _updateUsername(String username) async { diff --git a/pubspec.yaml b/pubspec.yaml index 68b04d3..125a52c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,7 @@ description: "twonly, a privacy-friendly way to connect with friends through sec publish_to: 'none' -version: 0.0.82+82 +version: 0.0.83+83 environment: sdk: ^3.6.0