This commit is contained in:
otsmr 2025-04-21 17:56:25 +02:00
parent 68e8c09c07
commit 1e89809f27
3 changed files with 16 additions and 1 deletions

View file

@ -30,6 +30,7 @@ void main() async {
apiProvider = ApiProvider();
twonlyDatabase = TwonlyDatabase();
await twonlyDatabase.messagesDao.appRestarted();
runApp(
MultiProvider(

View file

@ -104,6 +104,20 @@ class MessagesDao extends DatabaseAccessor<TwonlyDatabase>
.write(updates);
}
Future appRestarted() {
// All media files in the downloading state are reseteded to the pending state
// When the app is used in mobile network, they will not be downloaded at the start
// if they are not yet downloaded...
final updates =
MessagesCompanion(downloadState: Value(DownloadState.pending));
return (update(messages)
..where((t) =>
t.messageOtherId.isNotNull() &
t.downloadState.equals(DownloadState.downloading.index) &
t.kind.equals(MessageKind.media.name)))
.write(updates);
}
Future openedAllNonMediaMessagesFromOtherUser(int contactId) {
final updates = MessagesCompanion(openedAt: Value(DateTime.now()));
return (update(messages)

View file

@ -27,7 +27,7 @@ Future tryDownloadAllMediaFiles() async {
MessageContent.fromJson(message.kind, jsonDecode(message.contentJson!));
if (content is MediaMessageContent) {
tryDownloadMedia(
await tryDownloadMedia(
message.messageId,
message.contactId,
content,