From 4833b9027fd17c91e798c192998bb733e01f7d6a Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Tue, 11 Jun 2019 12:45:14 +0200 Subject: [PATCH] Queries for direct, groups and archived rooms --- lib/src/Store.dart | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/src/Store.dart b/lib/src/Store.dart index ab60c3a..f19df3c 100644 --- a/lib/src/Store.dart +++ b/lib/src/Store.dart @@ -435,13 +435,16 @@ class Store { } /// Returns all rooms, the client is participating. Excludes left rooms. - Future> getRoomList() async { + Future> getRoomList({bool onlyLeft = false, bool onlyDirect = false, bool onlyGroups=false}) async { + if (onlyDirect && onlyGroups) return []; List> res = await db.rawQuery( - "SELECT rooms.id, rooms.topic, rooms.membership, rooms.notification_count, rooms.highlight_count, rooms.avatar_url, rooms.unread, " + - " events.id AS eventsid, origin_server_ts, events.content_body, events.sender, events.state_key, events.content_json, events.type " + + "SELECT * " + " FROM Rooms rooms LEFT JOIN Events events " + " ON rooms.id=events.chat_id " + - " WHERE rooms.membership!='leave' " + + " WHERE rooms.id!='' " + + " AND rooms.membership" + (onlyLeft ? "=" : "!=") +"'left' " + + (onlyDirect ? " AND rooms.direct_chat_matrix_id!= '' " : "") + + (onlyGroups ? " AND rooms.direct_chat_matrix_id= '' " : "") + " GROUP BY rooms.id " + " ORDER BY origin_server_ts DESC "); List roomList = [];