mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-01-15 20:38:40 +00:00
fix #117
This commit is contained in:
parent
68e8c09c07
commit
1e89809f27
3 changed files with 16 additions and 1 deletions
|
|
@ -30,6 +30,7 @@ void main() async {
|
||||||
|
|
||||||
apiProvider = ApiProvider();
|
apiProvider = ApiProvider();
|
||||||
twonlyDatabase = TwonlyDatabase();
|
twonlyDatabase = TwonlyDatabase();
|
||||||
|
await twonlyDatabase.messagesDao.appRestarted();
|
||||||
|
|
||||||
runApp(
|
runApp(
|
||||||
MultiProvider(
|
MultiProvider(
|
||||||
|
|
|
||||||
|
|
@ -104,6 +104,20 @@ class MessagesDao extends DatabaseAccessor<TwonlyDatabase>
|
||||||
.write(updates);
|
.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) {
|
Future openedAllNonMediaMessagesFromOtherUser(int contactId) {
|
||||||
final updates = MessagesCompanion(openedAt: Value(DateTime.now()));
|
final updates = MessagesCompanion(openedAt: Value(DateTime.now()));
|
||||||
return (update(messages)
|
return (update(messages)
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ Future tryDownloadAllMediaFiles() async {
|
||||||
MessageContent.fromJson(message.kind, jsonDecode(message.contentJson!));
|
MessageContent.fromJson(message.kind, jsonDecode(message.contentJson!));
|
||||||
|
|
||||||
if (content is MediaMessageContent) {
|
if (content is MediaMessageContent) {
|
||||||
tryDownloadMedia(
|
await tryDownloadMedia(
|
||||||
message.messageId,
|
message.messageId,
|
||||||
message.contactId,
|
message.contactId,
|
||||||
content,
|
content,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue