From 19b192e7b9adeee74d57ff02faf001a68fc37720 Mon Sep 17 00:00:00 2001 From: Misaki Kasumi Date: Thu, 4 Jan 2024 16:46:19 +0800 Subject: [PATCH] avoid unneccessary rerender --- src/monitor.ts | 13 ++++++++----- src/style.ts | 4 +++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/monitor.ts b/src/monitor.ts index 1d6d309..97f6698 100644 --- a/src/monitor.ts +++ b/src/monitor.ts @@ -82,7 +82,7 @@ export class Manager { if (value) { const item = monitor.features[idx]; if (item) { - item.value = value; + Object.assign(item.value, value); } else { monitor.features.push({ name, @@ -137,10 +137,13 @@ export class Manager { value, }); await timeout(settings.updateInterval); - feature.value = await invoke("get_monitor_feature", { - id, - feature: name, - }); + Object.assign( + feature.value, + await invoke("get_monitor_feature", { + id, + feature: name, + }), + ); } } } diff --git a/src/style.ts b/src/style.ts index f30536f..85e6103 100644 --- a/src/style.ts +++ b/src/style.ts @@ -16,7 +16,9 @@ const colors = reactive({}); watchThrottled( () => panelState.focused, async () => { - Object.assign(colors, await invoke("get_accent_colors")); + for (const [name, color] of Object.entries(await invoke("get_accent_colors"))) { + colors[name] = Object.assign(colors[name] ?? {}, color); + } }, { throttle: 1000, immediate: true }, );