mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-01-15 16:48:41 +00:00
fix #88
This commit is contained in:
parent
511358d047
commit
f485366719
3 changed files with 24 additions and 7 deletions
|
|
@ -149,7 +149,7 @@ class _MessageSendStateIconState extends State<MessageSendStateIcon> {
|
||||||
if (message.errorWhileSending) {
|
if (message.errorWhileSending) {
|
||||||
icon =
|
icon =
|
||||||
FaIcon(FontAwesomeIcons.circleExclamation, size: 12, color: color);
|
FaIcon(FontAwesomeIcons.circleExclamation, size: 12, color: color);
|
||||||
text = "Error while sending";
|
text = "Unknown error.";
|
||||||
}
|
}
|
||||||
|
|
||||||
icons.add(icon);
|
icons.add(icon);
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,10 @@ class MessagesDao extends DatabaseAccessor<TwonlyDatabase>
|
||||||
|
|
||||||
Stream<List<Message>> watchMessageNotOpened(int contactId) {
|
Stream<List<Message>> watchMessageNotOpened(int contactId) {
|
||||||
return (select(messages)
|
return (select(messages)
|
||||||
..where((t) => t.openedAt.isNull() & t.contactId.equals(contactId))
|
..where((t) =>
|
||||||
|
t.openedAt.isNull() &
|
||||||
|
t.contactId.equals(contactId) &
|
||||||
|
t.errorWhileSending.equals(false))
|
||||||
..orderBy([(t) => OrderingTerm.desc(t.sendAt)]))
|
..orderBy([(t) => OrderingTerm.desc(t.sendAt)]))
|
||||||
.watch();
|
.watch();
|
||||||
}
|
}
|
||||||
|
|
@ -55,8 +58,12 @@ class MessagesDao extends DatabaseAccessor<TwonlyDatabase>
|
||||||
Future removeOldMessages() {
|
Future removeOldMessages() {
|
||||||
return (update(messages)
|
return (update(messages)
|
||||||
..where((t) =>
|
..where((t) =>
|
||||||
t.openedAt.isSmallerThanValue(
|
(t.openedAt.isSmallerThanValue(
|
||||||
DateTime.now().subtract(Duration(days: 1))) &
|
DateTime.now().subtract(Duration(days: 1)),
|
||||||
|
) |
|
||||||
|
(t.sendAt.isSmallerThanValue(
|
||||||
|
DateTime.now().subtract(Duration(days: 1))) &
|
||||||
|
t.errorWhileSending.equals(true))) &
|
||||||
t.kind.equals(MessageKind.textMessage.name)))
|
t.kind.equals(MessageKind.textMessage.name)))
|
||||||
.write(MessagesCompanion(contentJson: Value(null)));
|
.write(MessagesCompanion(contentJson: Value(null)));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
import 'package:drift/drift.dart' hide Column;
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
import 'package:lottie/lottie.dart';
|
import 'package:lottie/lottie.dart';
|
||||||
import 'package:no_screenshot/no_screenshot.dart';
|
import 'package:no_screenshot/no_screenshot.dart';
|
||||||
|
|
@ -91,7 +91,7 @@ class _MediaViewerViewState extends State<MediaViewerView> {
|
||||||
|
|
||||||
Future loadCurrentMediaFile({bool showTwonly = false}) async {
|
Future loadCurrentMediaFile({bool showTwonly = false}) async {
|
||||||
await _noScreenshot.screenshotOff();
|
await _noScreenshot.screenshotOff();
|
||||||
if (!context.mounted || allMediaFiles.isEmpty) return;
|
if (!context.mounted || allMediaFiles.isEmpty) return nextMediaOrExit();
|
||||||
|
|
||||||
final current = allMediaFiles.first;
|
final current = allMediaFiles.first;
|
||||||
final MediaMessageContent content =
|
final MediaMessageContent content =
|
||||||
|
|
@ -137,14 +137,24 @@ class _MediaViewerViewState extends State<MediaViewerView> {
|
||||||
do {
|
do {
|
||||||
if (isDownloading) {
|
if (isDownloading) {
|
||||||
await Future.delayed(Duration(milliseconds: 10));
|
await Future.delayed(Duration(milliseconds: 10));
|
||||||
|
if (!apiProvider.isConnected) break;
|
||||||
}
|
}
|
||||||
if (content.downloadToken == null) break;
|
if (content.downloadToken == null) break;
|
||||||
imageBytes = await getDownloadedMedia(current, content.downloadToken!);
|
imageBytes = await getDownloadedMedia(current, content.downloadToken!);
|
||||||
} while (isDownloading && imageBytes == null);
|
} while (isDownloading && imageBytes == null);
|
||||||
|
|
||||||
isDownloading = false;
|
isDownloading = false;
|
||||||
|
|
||||||
if (imageBytes == null) {
|
if (imageBytes == null) {
|
||||||
|
if (current.downloadState == DownloadState.downloaded) {
|
||||||
|
// When the message should be downloaded but imageBytes are null then a error happened
|
||||||
|
await twonlyDatabase.messagesDao.updateMessageByMessageId(
|
||||||
|
current.messageId,
|
||||||
|
MessagesCompanion(
|
||||||
|
errorWhileSending: Value(true),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
nextMediaOrExit();
|
nextMediaOrExit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue