Philipp Hörist pushed to branch storage at gajim / gajim


Commits:
59f681ba by Philipp Hörist at 2023-11-18T18:05:33+01:00
cq: Fixes

- - - - -


6 changed files:

- gajim/common/storage/archive/storage.py
- gajim/common/storage/archive/structs.py
- gajim/common/structs.py
- gajim/gtk/chat_list.py
- gajim/gtk/control.py
- gajim/gtk/conversation/view.py


Changes:

=====================================
gajim/common/storage/archive/storage.py
=====================================
@@ -97,7 +97,7 @@ def _row_factory(
 
 
 def namedtuple_row(cursor: sqlite.Cursor, row: tuple[Any, ...]) -> Any:
-    fields = [column[0] for column in cursor.description]  # pyright: ignore
+    fields = [column[0] for column in cursor.description]
     cls = namedtuple('Row', fields)  # pyright: ignore
     return cls._make(row)
 


=====================================
gajim/common/storage/archive/structs.py
=====================================
@@ -558,7 +558,7 @@ class DbBaseJoinedRowData:
     def from_row(
         cls,
         column_names: list[str],
-        row: tuple[Any]
+        row: tuple[Any, ...]
     ):
 
         tkv: dict[str, Any] = {}


=====================================
gajim/common/structs.py
=====================================
@@ -38,8 +38,8 @@
 from gajim.common.const import MUCJoinedState
 from gajim.common.const import PresenceShowExt
 from gajim.common.const import URIType
-from gajim.common.util.datetime import convert_epoch_to_local_datetime
 from gajim.common.storage.archive.const import MessageType
+from gajim.common.util.datetime import convert_epoch_to_local_datetime
 
 _T = TypeVar('_T')
 


=====================================
gajim/gtk/chat_list.py
=====================================
@@ -609,6 +609,9 @@ def _on_message_received(self, event: 
events.MessageReceived) -> None:
         if joined_data.message is None:
             return
 
+        assert joined_data.stanza_id is not None
+        assert joined_data.message_id is not None
+
         nick = self._get_nick_for_received_message(event.account, joined_data)
         row.set_nick(nick)
         row.set_timestamp(joined_data.timestamp)


=====================================
gajim/gtk/control.py
=====================================
@@ -512,9 +512,9 @@ def _add_messages(self, messages: 
list[DbConversationJoinedData]):
 
     def _request_messages(self, before: bool) -> 
list[DbConversationJoinedData]:
         if before:
-            row = self._scrolled_view.get_first_message_row()
+            row = self._scrolled_view.get_first_row()
         else:
-            row = self._scrolled_view.get_last_message_row()
+            row = self._scrolled_view.get_last_row()
 
         if row is None:
             timestamp = time.time()


=====================================
gajim/gtk/conversation/view.py
=====================================
@@ -381,20 +381,38 @@ def _get_row_at_index(self, index: int) -> BaseRow:
         assert row is not None
         return cast(BaseRow, row)
 
-    def get_first_message_row(self
+    def get_first_row(self
     ) -> MessageRow | CallRow | FileTransferJingleRow | None:
         for row in self._list_box.get_children():
             if isinstance(row, MessageRow | CallRow | FileTransferJingleRow):
                 return row
         return None
 
-    def get_last_message_row(self) -> MessageRow | CallRow | 
FileTransferJingleRow | None:
+    def get_last_row(
+        self
+    ) -> MessageRow | CallRow | FileTransferJingleRow | None:
         children = reversed(self._list_box.get_children())
         for row in children:
             if isinstance(row, MessageRow | CallRow | FileTransferJingleRow):
                 return row
         return None
 
+    def get_first_message_row(self
+    ) -> MessageRow | None:
+        for row in self._list_box.get_children():
+            if isinstance(row, MessageRow):
+                return row
+        return None
+
+    def get_last_message_row(
+        self
+    ) -> MessageRow | None:
+        children = reversed(self._list_box.get_children())
+        for row in children:
+            if isinstance(row, MessageRow):
+                return row
+        return None
+
     def get_first_event_row(self) -> InfoMessage | MUCJoinLeft | None:
         for row in self._list_box.get_children():
             if isinstance(row, InfoMessage | MUCJoinLeft):



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/59f681ba7afeb89e2398aefde495a0f47988d966

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/59f681ba7afeb89e2398aefde495a0f47988d966
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to