Not loading favorite if base program renamed

This commit is contained in:
Andre Basche 2023-07-22 11:48:40 +02:00
parent 0c1670733f
commit 6cdac99ce8

View File

@ -187,18 +187,19 @@ class HonCommandLoader:
command = favourite.get("command", {}) command = favourite.get("command", {})
command_name = command.get("commandName", "") command_name = command.get("commandName", "")
program_name = self._clean_name(command.get("programName", "")) program_name = self._clean_name(command.get("programName", ""))
base: HonCommand = copy( if not (base := self.commands[command_name].categories.get(program_name)):
self.commands[command_name].categories[program_name] continue
) base_command: HonCommand = copy(base)
for data in command.values(): for data in command.values():
if isinstance(data, str): if isinstance(data, str):
continue continue
for key, value in data.items(): for key, value in data.items():
if parameter := base.parameters.get(key): if parameter := base_command.parameters.get(key):
with suppress(ValueError): with suppress(ValueError):
parameter.value = value parameter.value = value
extra_param = HonParameterFixed("favourite", {"fixedValue": "1"}, "custom") extra_param = HonParameterFixed("favourite", {"fixedValue": "1"}, "custom")
base.parameters.update(favourite=extra_param) base_command.parameters.update(favourite=extra_param)
if isinstance(program := base.parameters["program"], HonParameterProgram): program = base_command.parameters["program"]
if isinstance(program, HonParameterProgram):
program.set_value(name) program.set_value(name)
self.commands[command_name].categories[name] = base self.commands[command_name].categories[name] = base_command