From b362ef5610f38d787b3dbeb510e05401bff709b9 Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Fri, 24 Jan 2020 09:34:38 +0000 Subject: [PATCH] [Store] Simplify store API --- lib/src/room.dart | 9 +-------- lib/src/store_api.dart | 30 ++++++++---------------------- 2 files changed, 9 insertions(+), 30 deletions(-) diff --git a/lib/src/room.dart b/lib/src/room.dart index b46e3fd..d41e789 100644 --- a/lib/src/room.dart +++ b/lib/src/room.dart @@ -604,8 +604,7 @@ class Room { ); client.onEvent.add(eventUpdate); client.store.storeEventUpdate(eventUpdate); - client.store.txn.rawUpdate( - "UPDATE Rooms SET prev_batch=? WHERE room_id=?", [resp["end"], id]); + client.store.setRoomPrevBatch(id, resp["end"]); } return; }); @@ -744,12 +743,6 @@ class Room { return timeline; } - /// Load all participants for a given room from the store. - @deprecated - Future> loadParticipants() async { - return await client.store.loadParticipants(this); - } - /// Returns all participants for this room. With lazy loading this /// list may not be complete. User [requestParticipants] in this /// case. diff --git a/lib/src/store_api.dart b/lib/src/store_api.dart index dd3bce5..ab19281 100644 --- a/lib/src/store_api.dart +++ b/lib/src/store_api.dart @@ -38,16 +38,16 @@ import 'sync/user_update.dart'; abstract class StoreAPI { Client client; - Future queryPrevBatch(); - /// Will be automatically called when the client is logged in successfully. Future storeClient(); /// Clears all tables from the database. Future clear(); - var txn; + /// The current trans + Future setRoomPrevBatch(String roomId, String prevBatch); + /// Performs these query or queries inside of an transaction. Future transaction(void queries()); /// Will be automatically called on every synchronisation. Must be called inside of @@ -71,41 +71,27 @@ abstract class StoreAPI { /// Returns a User object by a given Matrix ID and a Room. Future getUser({String matrixID, Room room}); - /// Loads all Users in the database to provide a contact list - /// except users who are in the Room with the ID [exceptRoomID]. - Future> loadContacts({String exceptRoomID = ""}); - - /// Returns all users of a room by a given [roomID]. - Future> loadParticipants(Room room); - /// Returns a list of events for the given room and sets all participants. Future> getEventList(Room room); /// Returns all rooms, the client is participating. Excludes left rooms. Future> getRoomList({bool onlyLeft = false}); - /// Returns a room without events and participants. - @deprecated - Future getRoomById(String id); - - Future>> getStatesFromRoomId(String id); - + /// Deletes this room from the database. Future forgetRoom(String roomID); + /// Sets notification and highlight count to 0 for this room. Future resetNotificationCount(String roomID); /// Searches for the event in the store. Future getEventById(String eventID, Room room); + /// Returns all account data for this client. Future> getAccountData(); + /// Returns all stored presences for this client. Future> getPresences(); + /// Removes this event from the store. Future removeEvent(String eventId); - - Future forgetNotification(String roomID); - - Future addNotification(String roomID, String event_id, int uniqueID); - - Future>> getNotificationByRoom(String room_id); }