From ee6cc9fd4fd6df5230f448cb75fb1184c40f5726 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Thu, 23 Sep 2021 17:45:01 +0200 Subject: [PATCH] Improved conversation sorting --- nomadnet/Conversation.py | 1 + nomadnet/ui/textui/Conversations.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/nomadnet/Conversation.py b/nomadnet/Conversation.py index a3fcd7a..a6d3b59 100644 --- a/nomadnet/Conversation.py +++ b/nomadnet/Conversation.py @@ -236,6 +236,7 @@ class ConversationMessage: self.lxm = LXMF.LXMessage.unpack_from_file(open(self.file_path, "rb")) self.loaded = True self.timestamp = self.lxm.timestamp + self.sort_timestamp = os.path.getmtime(self.file_path) if self.lxm.state > LXMF.LXMessage.DRAFT and self.lxm.state < LXMF.LXMessage.SENT: found = False diff --git a/nomadnet/ui/textui/Conversations.py b/nomadnet/ui/textui/Conversations.py index d48a0c9..e1018af 100644 --- a/nomadnet/ui/textui/Conversations.py +++ b/nomadnet/ui/textui/Conversations.py @@ -665,7 +665,7 @@ class ConversationWidget(urwid.WidgetWrap): message_widget = LXMessageWidget(message) self.message_widgets.append(message_widget) - self.message_widgets.sort(key=lambda m: m.timestamp, reverse=False) + self.message_widgets.sort(key=lambda m: m.sort_timestamp, reverse=False) from nomadnet.vendor.additional_urwid_widgets import IndicativeListBox self.messagelist = IndicativeListBox(self.message_widgets, position = len(self.message_widgets)-1) @@ -699,6 +699,7 @@ class LXMessageWidget(urwid.WidgetWrap): app = nomadnet.NomadNetworkApp.get_shared_instance() g = app.ui.glyphs self.timestamp = message.get_timestamp() + self.sort_timestamp = message.sort_timestamp time_format = app.time_format message_time = datetime.fromtimestamp(self.timestamp) encryption_string = ""