From df8e98366bc9a0b9e54cc7add78db70d628f1a2b Mon Sep 17 00:00:00 2001 From: liamcottle Date: Mon, 3 Feb 2025 00:13:00 +1300 Subject: [PATCH] remove existing sub interfaces when saving an rnode multi interface --- meshchat.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/meshchat.py b/meshchat.py index fa9e297..11a3ae3 100644 --- a/meshchat.py +++ b/meshchat.py @@ -634,8 +634,6 @@ class ReticulumMeshChat: # handle RNodeMultiInterface if interface_type == "RNodeMultiInterface": - # FIXME: currently not possible to remove a sub interface after it has already been saved - # required settings interface_port = data.get("port") sub_interfaces = data.get("sub_interfaces", []) @@ -655,6 +653,14 @@ class ReticulumMeshChat: # set required RNodeMultiInterface options interface_details["port"] = interface_port + # remove any existing sub interfaces, which can be found by finding keys that contain a dict value + # this allows us to replace all sub interfaces with the ones we are about to add, while also ensuring + # that we do not remove any existing config values from the main interface config + for key in interface_details: + value = interface_details[key] + if isinstance(value, dict): + del interface_details[key] + # process each provided sub interface for idx, sub_interface in enumerate(sub_interfaces):