mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-01-15 12:28:40 +00:00
improve error handling
This commit is contained in:
parent
f6ce7c83db
commit
6715081d89
2 changed files with 14 additions and 1 deletions
|
|
@ -8,6 +8,7 @@ import 'package:twonly/globals.dart';
|
|||
import 'package:twonly/src/database/twonly_database.dart';
|
||||
import 'package:twonly/src/database/tables/messages_table.dart';
|
||||
import 'package:twonly/src/model/json/message.dart';
|
||||
import 'package:twonly/src/providers/api/api_utils.dart';
|
||||
import 'package:twonly/src/providers/api/media_send.dart';
|
||||
import 'dart:typed_data';
|
||||
import 'package:cryptography_plus/cryptography_plus.dart';
|
||||
|
|
@ -130,7 +131,18 @@ Future startDownloadMedia(Message message, bool force) async {
|
|||
}
|
||||
|
||||
downloadStartedForMediaReceived[message.messageId] = DateTime.now();
|
||||
apiProvider.triggerDownload(content.downloadToken!, offset);
|
||||
Result res =
|
||||
await apiProvider.triggerDownload(content.downloadToken!, offset);
|
||||
if (res.isError) {
|
||||
if (res.error == ErrorCode.InvalidDownloadToken) {
|
||||
await twonlyDatabase.messagesDao.updateMessageByMessageId(
|
||||
media.messageId,
|
||||
MessagesCompanion(
|
||||
errorWhileSending: Value(true),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -208,6 +208,7 @@ class ApiProvider {
|
|||
|
||||
Result res = asResult(await _waitForResponse(seq));
|
||||
if (res.isError) {
|
||||
Logger("api_provider").shout("Got error from SERVER: ${res.error}");
|
||||
if (res.error == ErrorCode.SessionNotAuthenticated) {
|
||||
isAuthenticated = false;
|
||||
if (authenticated) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue