From 17e752d1345fb6ebd9025d7861eebd51c439c4df Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Thu, 13 May 2021 20:25:04 +0200 Subject: [PATCH] List sort fix --- nomadnet/Conversation.py | 9 +++++++-- nomadnet/ui/textui/Conversations.py | 6 ++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/nomadnet/Conversation.py b/nomadnet/Conversation.py index 868eb1f..fa250f6 100644 --- a/nomadnet/Conversation.py +++ b/nomadnet/Conversation.py @@ -45,16 +45,21 @@ class Conversation: if display_name == None and app_data: display_name = app_data.decode("utf-8") + + if display_name == None: + sort_name = "" + else: + sort_name = display_name trust_level = app.directory.trust_level(source_hash, display_name) - entry = (source_hash_text, display_name, trust_level) + entry = (source_hash_text, display_name, trust_level, sort_name) conversations.append(entry) except Exception as e: RNS.log("Error while loading conversation "+str(dirname)+", skipping it. The contained exception was: "+str(e), RNS.LOG_ERROR) - conversations.sort(key=lambda e: (-e[2], e[1], e[0]), reverse=False) + conversations.sort(key=lambda e: (-e[2], e[3], e[0]), reverse=False) return conversations diff --git a/nomadnet/ui/textui/Conversations.py b/nomadnet/ui/textui/Conversations.py index a22c381..2587980 100644 --- a/nomadnet/ui/textui/Conversations.py +++ b/nomadnet/ui/textui/Conversations.py @@ -59,7 +59,8 @@ class ConversationsDisplay(): if not self.dialog_open: ilb_position = self.ilb.get_selected_position() self.update_conversation_list() - self.ilb.select_item(ilb_position) + if ilb_position != None: + self.ilb.select_item(ilb_position) def update_listbox(self): @@ -183,7 +184,8 @@ class ConversationsDisplay(): self.update_listbox() options = self.columns_widget.options("weight", ConversationsDisplay.list_width) self.columns_widget.contents[0] = (self.listbox, options) - self.ilb.select_item(ilb_position) + if ilb_position != None: + self.ilb.select_item(ilb_position) nomadnet.NomadNetworkApp.get_shared_instance().ui.loop.draw_screen()