diff --git a/contact/localisations/en.ini b/contact/localisations/en.ini index fd7ad13..5216ab7 100644 --- a/contact/localisations/en.ini +++ b/contact/localisations/en.ini @@ -168,7 +168,7 @@ uplink_enabled, "Uplink enabled", "Let this channel's data be sent to the MQTT s downlink_enabled, "Downlink enabled", "Let data from the MQTT server configured on this node be sent to this channel." module_settings, "Module settings", "Position precision and Client Mute." module_settings.position_precision, "Position precision", "The precision level of location data sent on this channel." -module_settings.is_client_muted, "Is Client Muted", "Controls whether or not the phone / clients should mute the current channel. Useful for noisy public channels you don't necessarily want to disable." +module_settings.is_muted, "Is muted", "Controls whether or not the client or device should mute this channel. Useful for noisy public channels you do not necessarily want to disable." [config.device] title, "Device" diff --git a/contact/utilities/save_to_radio.py b/contact/utilities/save_to_radio.py index a102526..a541148 100644 --- a/contact/utilities/save_to_radio.py +++ b/contact/utilities/save_to_radio.py @@ -161,7 +161,8 @@ def save_changes(interface, modified_settings, menu_state, node=None): config_category = "Channels" try: - channel = menu_state.menu_path[-1] + channels_index = menu_state.menu_path.index("Channels") + channel = menu_state.menu_path[channels_index + 1] channel_num = int(channel.split()[-1]) - 1 except (IndexError, ValueError) as e: channel_num = None @@ -170,8 +171,10 @@ def save_changes(interface, modified_settings, menu_state, node=None): for key, value in modified_settings.items(): if key == "psk": # Special case: decode Base64 for psk channel.settings.psk = base64.b64decode(value) - elif key == "position_precision": # Special case: module_settings - channel.settings.module_settings.position_precision = value + elif key in {"position_precision", "is_muted"}: + # These fields belong to ChannelSettings.module_settings, + # not ChannelSettings itself. + setattr(channel.settings.module_settings, key, value) else: setattr(channel.settings, key, value) # Use setattr for other fields diff --git a/tests/test_save_to_radio.py b/tests/test_save_to_radio.py index d52b19d..c022581 100644 --- a/tests/test_save_to_radio.py +++ b/tests/test_save_to_radio.py @@ -95,6 +95,18 @@ class SaveToRadioTests(unittest.TestCase): self.assertTrue(reconnect_required) self.assertTrue(node.moduleConfig.mqtt.enabled) + def test_save_changes_writes_channel_is_muted_to_module_settings(self) -> None: + interface, node = self.build_interface() + channel = SimpleNamespace(settings=SimpleNamespace(module_settings=SimpleNamespace(is_muted=False)), role=None) + node.channels = [channel] + menu_state = SimpleNamespace(menu_path=["Main Menu", "Channels", "Channel 1", "module_settings"]) + + reconnect_required = save_changes(interface, {"is_muted": True}, menu_state) + + self.assertFalse(reconnect_required) + self.assertTrue(channel.settings.module_settings.is_muted) + node.writeChannel.assert_called_once_with(0) + def test_save_changes_returns_true_for_user_name_changes(self) -> None: interface, node = self.build_interface() menu_state = SimpleNamespace(menu_path=["Main Menu", "User Settings"])