fix: Mark pending events as failed on startup
This commit is contained in:
parent
aa9940fdbc
commit
5d45c224a3
|
@ -143,6 +143,7 @@ class Database extends _$Database {
|
||||||
Future<DbClient> getClient(String name) async {
|
Future<DbClient> getClient(String name) async {
|
||||||
final res = await dbGetClient(name).get();
|
final res = await dbGetClient(name).get();
|
||||||
if (res.isEmpty) return null;
|
if (res.isEmpty) return null;
|
||||||
|
await markPendingEventsAsError(res.first.clientId);
|
||||||
return res.first;
|
return res.first;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6514,6 +6514,15 @@ abstract class _$Database extends GeneratedDatabase {
|
||||||
readsFrom: {files}).map(_rowToDbFile);
|
readsFrom: {files}).map(_rowToDbFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<int> markPendingEventsAsError(int client_id) {
|
||||||
|
return customUpdate(
|
||||||
|
'UPDATE events SET status = -1 WHERE client_id = :client_id AND status = 0',
|
||||||
|
variables: [Variable.withInt(client_id)],
|
||||||
|
updates: {events},
|
||||||
|
updateKind: UpdateKind.update,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Iterable<TableInfo> get allTables => allSchemaEntities.whereType<TableInfo>();
|
Iterable<TableInfo> get allTables => allSchemaEntities.whereType<TableInfo>();
|
||||||
@override
|
@override
|
||||||
|
|
|
@ -233,3 +233,4 @@ removeRoom: DELETE FROM rooms WHERE client_id = :client_id AND room_id = :room_i
|
||||||
removeRoomEvents: DELETE FROM events WHERE client_id = :client_id AND room_id = :room_id;
|
removeRoomEvents: DELETE FROM events WHERE client_id = :client_id AND room_id = :room_id;
|
||||||
storeFile: INSERT OR REPLACE INTO files (mxc_uri, bytes, saved_at) VALUES (:mxc_uri, :bytes, :time);
|
storeFile: INSERT OR REPLACE INTO files (mxc_uri, bytes, saved_at) VALUES (:mxc_uri, :bytes, :time);
|
||||||
dbGetFile: SELECT * FROM files WHERE mxc_uri = :mxc_uri;
|
dbGetFile: SELECT * FROM files WHERE mxc_uri = :mxc_uri;
|
||||||
|
markPendingEventsAsError: UPDATE events SET status = -1 WHERE client_id = :client_id AND status = 0;
|
||||||
|
|
Loading…
Reference in a new issue