From 0761d33b6fffbda1de500ebb5a43136669db3921 Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Wed, 7 Oct 2020 13:42:23 +0200 Subject: [PATCH] refactor: Database first to single --- lib/src/database/database.dart | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/src/database/database.dart b/lib/src/database/database.dart index a61dfa3..9de2ff3 100644 --- a/lib/src/database/database.dart +++ b/lib/src/database/database.dart @@ -164,8 +164,8 @@ class Database extends _$Database { Future getClient(String name) async { final res = await dbGetClient(name).get(); if (res.isEmpty) return null; - await markPendingEventsAsError(res.first.clientId); - return res.first; + await markPendingEventsAsError(res.single.clientId); + return res.single; } Future> getUserDeviceKeys( @@ -216,7 +216,7 @@ class Database extends _$Database { if (res.isEmpty) { return null; } - return res.first; + return res.single; } Future> getDbInboundGroupSessions( @@ -231,7 +231,7 @@ class Database extends _$Database { if (res.isEmpty) { return null; } - return res.first; + return res.single; } Future getSSSSCache(int clientId, String type) async { @@ -239,7 +239,7 @@ class Database extends _$Database { if (res.isEmpty) { return null; } - return res.first; + return res.single; } Future> getRoomList(sdk.Client client, @@ -563,7 +563,7 @@ class Database extends _$Database { if (event.isEmpty) { return null; } - return sdk.Event.fromDb(event.first, room); + return sdk.Event.fromDb(event.single, room); } Future redactMessage(int clientId, sdk.EventUpdate eventUpdate) async { @@ -649,7 +649,7 @@ class Database extends _$Database { if (res.isEmpty) { return null; } - return sdk.Event.fromDb(res.first, room).asUser; + return sdk.Event.fromDb(res.single, room).asUser; } Future> getUsers(int clientId, sdk.Room room) async { @@ -673,6 +673,6 @@ class Database extends _$Database { Future getFile(String mxcUri) async { final res = await dbGetFile(mxcUri).get(); if (res.isEmpty) return null; - return res.first.bytes; + return res.single.bytes; } }