List sort fix

This commit is contained in:
Mark Qvist 2021-05-13 20:25:04 +02:00
parent c6cf11df36
commit 17e752d134
2 changed files with 11 additions and 4 deletions

View File

@ -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

View File

@ -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()