From d8581c981c231c805dc376d7fd0ec3565d6ea59f Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Wed, 29 Oct 2025 02:22:23 +0100 Subject: [PATCH] Refactored conversation list --- sbapp/main.py | 11 +- sbapp/sideband/core.py | 2 +- sbapp/ui/conversations.py | 355 -------------------------------------- 3 files changed, 3 insertions(+), 365 deletions(-) diff --git a/sbapp/main.py b/sbapp/main.py index c5dbc7e..8039d64 100644 --- a/sbapp/main.py +++ b/sbapp/main.py @@ -2704,11 +2704,6 @@ class SidebandApp(MDApp): if not self.conversations_view: self.conversations_view = Conversations(self) - # for child in self.conversations_view.ids.conversations_scrollview.children: - # self.conversations_view.ids.conversations_scrollview.remove_widget(child) - # self.conversations_view.ids.conversations_scrollview.effect_cls = ScrollEffect - # self.conversations_view.ids.conversations_scrollview.add_widget(self.conversations_view.get_widget()) - self.root.ids.screen_manager.current = "conversations_screen" if self.messages_view: self.messages_view.ids.messages_scrollview.active_conversation = None @@ -2866,12 +2861,10 @@ class SidebandApp(MDApp): dialog.dismiss() self.message_sync_dialog.d_content.ids.sync_progress.value = 0.1 self.message_sync_dialog.d_content.ids.sync_status.text = "" - - # self.sideband.cancel_lxmf_sync() + if self.sideband.message_router.propagation_transfer_state == LXMF.LXMRouter.PR_COMPLETE: + self.sideband.message_router.acknowledge_sync_completion(reset_state=True) def dl_stop(s): - # self.sideband.setstate("app.flags.lxmf_sync_dialog_open", False) - # dialog.dismiss() self.sideband.cancel_lxmf_sync() def cb(dt): self.widget_hide(self.sync_dialog.stop_button, True) diff --git a/sbapp/sideband/core.py b/sbapp/sideband/core.py index 91c88f8..4c62d36 100644 --- a/sbapp/sideband/core.py +++ b/sbapp/sideband/core.py @@ -5358,7 +5358,7 @@ class SidebandCore(): if new_msgs == 0: return "Done, no new messages" else: - return "Downloaded "+str(new_msgs)+" new messages" + return "Downloaded "+str(new_msgs)+" messages" else: return "Unknown" diff --git a/sbapp/ui/conversations.py b/sbapp/ui/conversations.py index 502a63c..e2491fc 100644 --- a/sbapp/ui/conversations.py +++ b/sbapp/ui/conversations.py @@ -280,9 +280,6 @@ class Conversations(): self.added_item_dests = [] def update(self): - # if self.app.sideband.getstate("app.flags.unread_conversations"): - # self.clear_list() - self.context_dests = self.app.sideband.list_conversations(conversations=self.app.include_conversations, objects=self.app.include_objects) view_title = "Conversations" @@ -436,361 +433,12 @@ class Conversations(): def update_widget(self): RNS.log("Updating conversation list widgets", RNS.LOG_DEBUG) - # if self.list == None: self.list = MDList() if self.conversation_list == None: self.conversation_list = ConversationList() self.ids.conversation_list_container.add_widget(self.conversation_list) - - # remove_widgets = [] - # for w in self.list.children: - # if not w.sb_uid in [e["dest"] for e in self.context_dests]: - # remove_widgets.append(w) - # self.added_item_dests.remove(w.sb_uid) - - # for w in remove_widgets: - # self.list.remove_widget(w) self.update_conversation_list() - # us = time.time() - # for conv in self.context_dests: - # context_dest = conv["dest"] - # conv_type = conv["type"] - # unread = conv["unread"] - # last_activity = conv["last_activity"] - - # peer_disp_name = multilingual_markup(escape_markup(str(self.app.sideband.peer_display_name(context_dest))).encode("utf-8")).decode("utf-8") - # if not context_dest in self.added_item_dests: - # existing_conv = self.app.sideband._db_conversation(context_dest) - # is_object = self.app.sideband.is_object(context_dest, conv_data=existing_conv) - # ptt_enabled = self.app.sideband.ptt_enabled(context_dest, conv_data=existing_conv) - # iconl = self.get_icon(conv) - # item = OneLineAvatarIconListItem(text=peer_disp_name, on_release=self.app.conversation_action) - # item.add_widget(iconl) - # item.last_activity = last_activity - # item.iconl = iconl - # item.sb_uid = context_dest - # item.sb_unread = unread - # iconl.sb_uid = context_dest - # item.conv_type = conv_type - - # def gen_edit(item): - # def x(): - # t_s = time.time() - # dest = self.conversation_dropdown.context_dest - # try: - # cd = self.app.sideband._db_conversation(dest) - # disp_name = self.app.sideband.raw_display_name(dest) - # is_trusted = self.app.sideband.is_trusted(dest, conv_data=cd) - # is_object = self.app.sideband.is_object(dest, conv_data=cd) - # ptt_enabled = self.app.sideband.ptt_enabled(dest, conv_data=cd) - # send_telemetry = self.app.sideband.should_send_telemetry(dest, conv_data=cd) - # allow_requests = self.app.sideband.requests_allowed_from(dest, conv_data=cd) - - # yes_button = MDRectangleFlatButton(text="Save",font_size=dp(18), theme_text_color="Custom", line_color=self.app.color_accept, text_color=self.app.color_accept) - # no_button = MDRectangleFlatButton(text="Cancel",font_size=dp(18)) - # dialog_content = ConvSettings(disp_name=disp_name, context_dest=RNS.hexrep(dest, delimit=False), trusted=is_trusted, - # telemetry=send_telemetry, allow_requests=allow_requests, is_object=is_object, ptt_enabled=ptt_enabled) - # dialog_content.ids.name_field.font_name = self.app.input_font - - # dialog = MDDialog( - # title="Edit Conversation", - # text= "With "+RNS.prettyhexrep(dest), - # type="custom", - # content_cls=dialog_content, - # buttons=[ yes_button, no_button ], - # # elevation=0, - # ) - # dialog.d_content = dialog_content - # def dl_yes(s): - # try: - # name = dialog.d_content.ids["name_field"].text - # trusted = dialog.d_content.ids["trusted_switch"].active - # telemetry = dialog.d_content.ids["telemetry_switch"].active - # allow_requests = dialog.d_content.ids["allow_requests_switch"].active - # conv_is_object = dialog.d_content.ids["is_object_switch"].active - # ptt_is_enabled = dialog.d_content.ids["ptt_enabled_switch"].active - # if trusted: - # self.app.sideband.trusted_conversation(dest) - # else: - # self.app.sideband.untrusted_conversation(dest) - - # if telemetry: - # self.app.sideband.send_telemetry_in_conversation(dest) - # else: - # self.app.sideband.no_telemetry_in_conversation(dest) - - # if allow_requests: - # self.app.sideband.allow_requests_from(dest) - # else: - # self.app.sideband.disallow_requests_from(dest) - - # if conv_is_object: - # self.app.sideband.conversation_set_object(dest, True) - # else: - # self.app.sideband.conversation_set_object(dest, False) - - # if ptt_is_enabled: - # RNS.log("Setting PTT enabled") - # self.app.sideband.conversation_set_ptt_enabled(dest, True) - # else: - # RNS.log("Setting PTT disabled") - # self.app.sideband.conversation_set_ptt_enabled(dest, False) - - # self.app.sideband.named_conversation(name, dest) - - # except Exception as e: - # RNS.log("Error while saving conversation settings: "+str(e), RNS.LOG_ERROR) - - # dialog.dismiss() - - # def cb(dt): - # self.update() - # Clock.schedule_once(cb, 0.2) - - # def dl_no(s): - # dialog.dismiss() - - # yes_button.bind(on_release=dl_yes) - # no_button.bind(on_release=dl_no) - # self.voice_dropdown.dismiss(); self.conversation_dropdown.dismiss() - # dialog.open() - # RNS.log("Generated edit dialog in "+str(RNS.prettytime(time.time()-t_s)), RNS.LOG_DEBUG) - - # except Exception as e: - # RNS.log("Error while creating conversation settings: "+str(e), RNS.LOG_ERROR) - - # return x - - # def gen_clear(item): - # def x(): - # if self.clear_dialog == None: - # yes_button = MDRectangleFlatButton(text="Yes",font_size=dp(18), theme_text_color="Custom", line_color=self.app.color_reject, text_color=self.app.color_reject) - # no_button = MDRectangleFlatButton(text="No",font_size=dp(18)) - - # self.clear_dialog = MDDialog( - # title="Clear all messages in conversation?", - # buttons=[ yes_button, no_button ], - # # elevation=0, - # ) - # def dl_yes(s): - # self.clear_dialog.dismiss() - # self.app.sideband.clear_conversation(self.conversation_dropdown.context_dest) - # def dl_no(s): - # self.clear_dialog.dismiss() - - # yes_button.bind(on_release=dl_yes) - # no_button.bind(on_release=dl_no) - - # self.voice_dropdown.dismiss(); self.conversation_dropdown.dismiss() - # self.clear_dialog.open() - # return x - - # def gen_clear_telemetry(item): - # def x(): - # if self.clear_telemetry_dialog == None: - # yes_button = MDRectangleFlatButton(text="Yes",font_size=dp(18), theme_text_color="Custom", line_color=self.app.color_reject, text_color=self.app.color_reject) - # no_button = MDRectangleFlatButton(text="No",font_size=dp(18)) - - # self.clear_telemetry_dialog = MDDialog( - # title="Clear all telemetry related to this peer?", - # buttons=[ yes_button, no_button ], - # # elevation=0, - # ) - # def dl_yes(s): - # self.clear_telemetry_dialog.dismiss() - # self.app.sideband.clear_telemetry(self.conversation_dropdown.context_dest) - # def dl_no(s): - # self.clear_telemetry_dialog.dismiss() - - # yes_button.bind(on_release=dl_yes) - # no_button.bind(on_release=dl_no) - - # self.voice_dropdown.dismiss(); self.conversation_dropdown.dismiss() - # self.clear_telemetry_dialog.open() - # return x - - # def gen_del(item): - # def x(): - # if self.delete_dialog == None: - # yes_button = MDRectangleFlatButton(text="Yes",font_size=dp(18), theme_text_color="Custom", line_color=self.app.color_reject, text_color=self.app.color_reject) - # no_button = MDRectangleFlatButton(text="No",font_size=dp(18)) - # self.delete_dialog = MDDialog( - # title="Delete conversation?", - # buttons=[ yes_button, no_button ], - # # elevation=0, - # ) - # def dl_yes(s): - # self.delete_dialog.dismiss() - # self.app.sideband.delete_conversation(self.conversation_dropdown.context_dest) - # def cb(dt): - # self.update() - # Clock.schedule_once(cb, 0.2) - # def dl_no(s): - # self.delete_dialog.dismiss() - - # yes_button.bind(on_release=dl_yes) - # no_button.bind(on_release=dl_no) - - # self.voice_dropdown.dismiss(); self.conversation_dropdown.dismiss() - # self.delete_dialog.open() - # return x - - # def gen_copy_addr(item): - # def x(): - # Clipboard.copy(RNS.hexrep(self.conversation_dropdown.context_dest, delimit=False)) - # self.voice_dropdown.dismiss(); self.conversation_dropdown.dismiss() - # return x - - # def gen_call(item): - # def x(): - # identity = RNS.Identity.recall(self.conversation_dropdown.context_dest) - # if identity: self.app.dial_action(identity.hash) - # else: toast("Can't call, identity unknown") - # self.voice_dropdown.dismiss(); self.conversation_dropdown.dismiss() - # return x - - # item.iconr = IconRightWidget(icon="dots-vertical"); - - # if self.voice_dropdown == None: - # dmi_h = 40 - # dmv_items = [ - # { - # "viewclass": "OneLineListItem", - # "text": "Edit", - # "height": dp(dmi_h), - # "on_release": gen_edit(item) - # }, - # { - # "text": "Copy Identity Hash", - # "viewclass": "OneLineListItem", - # "height": dp(dmi_h), - # "on_release": gen_copy_addr(item) - # }, - # { - # "text": "Delete", - # "viewclass": "OneLineListItem", - # "height": dp(dmi_h), - # "on_release": gen_del(item) - # } - # ] - - # self.voice_dropdown = MDDropdownMenu( - # caller=item.iconr, - # items=dmv_items, - # position="auto", - # width=dp(256), - # elevation=0, - # radius=dp(3), - # ) - # self.voice_dropdown.effect_cls = ScrollEffect - # self.voice_dropdown.md_bg_color = self.app.color_hover - - # if self.conversation_dropdown == None: - # dmi_h = 40 - # dm_items = [ - # { - # "viewclass": "OneLineListItem", - # "text": "Edit", - # "height": dp(dmi_h), - # "on_release": gen_edit(item) - # }, - # { - # "viewclass": "OneLineListItem", - # "text": "Call", - # "height": dp(dmi_h), - # "on_release": gen_call(item) - # }, - # { - # "text": "Copy Address", - # "viewclass": "OneLineListItem", - # "height": dp(dmi_h), - # "on_release": gen_copy_addr(item) - # }, - # { - # "text": "Clear Messages", - # "viewclass": "OneLineListItem", - # "height": dp(dmi_h), - # "on_release": gen_clear(item) - # }, - # { - # "text": "Clear Telemetry", - # "viewclass": "OneLineListItem", - # "height": dp(dmi_h), - # "on_release": gen_clear_telemetry(item) - # }, - # { - # "text": "Delete Conversation", - # "viewclass": "OneLineListItem", - # "height": dp(dmi_h), - # "on_release": gen_del(item) - # } - # ] - - # self.conversation_dropdown = MDDropdownMenu( - # caller=item.iconr, - # items=dm_items, - # position="auto", - # width=dp(256), - # elevation=0, - # radius=dp(3), - # ) - # self.conversation_dropdown.effect_cls = ScrollEffect - # self.conversation_dropdown.md_bg_color = self.app.color_hover - - # if conv_type == self.app.sideband.CONV_VOICE: - # item.dmenu = self.voice_dropdown - # else: - # item.dmenu = self.conversation_dropdown - - # def callback_factory(ref, dest): - # def x(sender): - # self.conversation_dropdown.context_dest = dest - # self.voice_dropdown.context_dest = dest - # ref.dmenu.caller = ref.iconr - # ref.dmenu.open() - # return x - - # item.iconr.bind(on_release=callback_factory(item, context_dest)) - - # item.add_widget(item.iconr) - - # item.trusted = self.app.sideband.is_trusted(context_dest, conv_data=existing_conv) - # item.conv_type = conv_type - - # self.added_item_dests.append(context_dest) - # self.list.add_widget(item) - - # else: - # for w in self.list.children: - # if w.sb_uid == context_dest: - # trust_icon = self.trust_icon(conv) - # trusted = conv["trust"] == 1 - # da = self.app.sideband.DEFAULT_APPEARANCE - # appearance = self.app.sideband.peer_appearance(context_dest, conv) - # if trusted and self.app.sideband.config["display_style_in_contact_list"] and appearance != None and appearance != da: - # fg = appearance[1] or da[1]; bg = appearance[2] or da[2] - # ti_color = "Custom" - # else: - # ti_color = None - - # w.last_activity = last_activity - # if ti_color != None: - # w.iconl.theme_icon_color = ti_color - # if bg != None: w.iconl.md_bg_color = bg - # if fg != None: w.iconl.icon_color = fg - # else: - # w.iconl.theme_icon_color = "Primary" - # w.iconl.md_bg_color = [0,0,0,0] - - # if w.iconl.icon != trust_icon: w.iconl.icon = trust_icon - # if w.sb_unread != unread: w.sb_unread = unread - # if w.text != peer_disp_name: w.text = peer_disp_name - - # self.list.children.sort(key=lambda w: (w.trusted, w.last_activity)) - - # RNS.log("Updated conversation list widgets in "+RNS.prettytime(time.time()-us), RNS.LOG_DEBUG) - def get_widget(self): return self.conversation_list @@ -819,9 +467,6 @@ MDScreen: ['account-plus', lambda x: root.app.new_conversation_action(self)], ] - # ScrollView: - # id: conversations_scrollview - MDBoxLayout: orientation: "vertical" id: conversation_list_container