From 5e1ede0bea19580d19d0fe15b690be09d4efd006 Mon Sep 17 00:00:00 2001 From: pdxlocations Date: Mon, 3 Feb 2025 18:01:38 -0800 Subject: [PATCH 1/2] init --- ui/curses_ui.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ui/curses_ui.py b/ui/curses_ui.py index 0133ee9..b3bd083 100644 --- a/ui/curses_ui.py +++ b/ui/curses_ui.py @@ -1,7 +1,9 @@ import curses import textwrap +import time from utilities.utils import get_channels, get_readable_duration, get_time_ago, refresh_node_list from settings import settings_menu +from input_handlers import get_list_input from message_handlers.tx_handler import send_message, send_traceroute from ui.colors import setup_colors, get_color from db_handler import get_name_from_database, update_node_info_in_db, is_chat_archived @@ -671,6 +673,20 @@ def main_ui(stdscr): draw_channel_list() draw_messages_window() + if(globals.current_window == 2): + curses.curs_set(0) + confirmation = get_list_input(f"Remove {get_name_from_database(globals.node_list[globals.selected_node])} from nodedb?", "no", ["yes", "no"]) + if confirmation == "yes": + globals.interface.localNode.removeNode(globals.node_list[globals.selected_node]) + globals.node_list.pop(globals.selected_node) + + draw_messages_window() + draw_node_list() + else: + draw_messages_window() + curses.curs_set(1) + continue + else: # Append typed character to input text if(isinstance(char, str)): From d22b3abc2f79a41e5aea5cc757718c5eae5a0ae8 Mon Sep 17 00:00:00 2001 From: Russell Schmidt Date: Wed, 2 Apr 2025 14:36:23 -0500 Subject: [PATCH 2/2] Make removing node from DB work Since the Python API doesn't update the nodes table itself, we can just modify it ourselves. This fixes removing a node so it doesn't just pop right back up immediately and seems to actually work now. --- contact/ui/curses_ui.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/contact/ui/curses_ui.py b/contact/ui/curses_ui.py index 0fdfd3a..831ef9a 100644 --- a/contact/ui/curses_ui.py +++ b/contact/ui/curses_ui.py @@ -300,6 +300,14 @@ def main_ui(stdscr): confirmation = get_list_input(f"Remove {get_name_from_database(globals.node_list[globals.selected_node])} from nodedb?", "no", ["yes", "no"]) if confirmation == "yes": globals.interface.localNode.removeNode(globals.node_list[globals.selected_node]) + + # Directly modifying the interface from client code - good? Bad? If it's stupid but it works, it's not supid? + del(globals.interface.nodesByNum[globals.node_list[globals.selected_node]]) + + # Convert to "!hex" representation that interface.nodes uses + hexid = f"!{hex(globals.node_list[globals.selected_node])[2:]}" + del(globals.interface.nodes[hexid]) + globals.node_list.pop(globals.selected_node) draw_messages_window()