From cd8d9b8e12b662718f0b33e725996f115e69d686 Mon Sep 17 00:00:00 2001 From: wurstsalat Date: Sat, 11 Nov 2023 18:08:27 +0100 Subject: fix: SearchView: Fix displaying results for newly created group chats Fixes #11681 --- gajim/common/storage/archive.py | 43 +++++++++++++++++++++++++++-------------- gajim/gtk/search_view.py | 5 +---- 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/gajim/common/storage/archive.py b/gajim/common/storage/archive.py index 4f6f3e8c0..c6d583dc7 100644 --- a/gajim/common/storage/archive.py +++ b/gajim/common/storage/archive.py @@ -126,6 +126,7 @@ class LastConversationRow(NamedTuple): class SearchLogRow(NamedTuple): account_id: int jid_id: int + jid: JID contact_name: str time: float kind: int @@ -283,10 +284,6 @@ class MessageArchiveStorage(SqliteStorage): self._jid_ids[row.jid] = row self._jid_ids_reversed[row.jid_id] = row - def get_jid_from_id(self, jid_id: int) -> JidsTableRow | None: - # Use get as a fail-safe for cases where the JID ID table is incomplete - return self._jid_ids_reversed.get(jid_id) - def get_jids_in_db(self) -> KeysView[JID]: return self._jid_ids.keys() @@ -583,10 +580,6 @@ class MessageArchiveStorage(SqliteStorage): ''' Search the conversation log for messages containing the `query` string. - The search can either span the complete log for the given - `account` and `jid` or be restricted to a single day by - specifying `date`. - :param account: The account :param jid: The jid for which we request the conversation @@ -622,9 +615,20 @@ class MessageArchiveStorage(SqliteStorage): users_query_string = 'AND UPPER(contact_name) IN (?)' sql = ''' - SELECT account_id, jid_id, contact_name, time, kind, show, message, - subject, additional_data, log_line_id - FROM logs NATURAL JOIN jids WHERE jid IN ({jids}) + SELECT + account_id, + jid_id, + jid as "jid [jid]", + contact_name, + time, + kind, + show, + message, + subject, + additional_data, + log_line_id + FROM logs NATURAL JOIN jids + WHERE jid IN ({jids}) AND account_id = {account_id} AND message LIKE like(?) AND kind NOT IN ({kinds}) @@ -699,9 +703,20 @@ class MessageArchiveStorage(SqliteStorage): users_query_string = 'AND UPPER(contact_name) IN (?)' sql = ''' - SELECT account_id, jid_id, contact_name, time, kind, show, message, - subject, additional_data, log_line_id - FROM logs WHERE message LIKE like(?) + SELECT + account_id, + jid_id, + jid as "jid [jid]", + contact_name, + time, + kind, + show, + message, + subject, + additional_data, + log_line_id + FROM logs NATURAL JOIN jids + WHERE message LIKE like(?) AND account_id IN ({account_ids}) AND kind NOT IN ({kinds}) {users_query} diff --git a/gajim/gtk/search_view.py b/gajim/gtk/search_view.py index f38c194e1..6ab3e5654 100644 --- a/gajim/gtk/search_view.py +++ b/gajim/gtk/search_view.py @@ -196,13 +196,10 @@ class SearchView(Gtk.Box): accounts = self._get_accounts() assert self._results_iterator is not None for msg in itertools.islice(self._results_iterator, 25): - archive_jid = app.storage.archive.get_jid_from_id(msg.jid_id) - if archive_jid is None: - continue result_row = ResultRow( msg, accounts[msg.account_id], - JID.from_string(archive_jid.jid)) + msg.jid) self._ui.results_listbox.add(result_row) -- cgit v1.2.3