Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

Commit

Permalink
avoid unneccessary rerender
Browse files Browse the repository at this point in the history
  • Loading branch information
ruihe774 committed Jan 4, 2024
1 parent 51ea282 commit 19b192e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
13 changes: 8 additions & 5 deletions src/monitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -137,10 +137,13 @@ export class Manager {
value,
});
await timeout(settings.updateInterval);
feature.value = await invoke<Reply>("get_monitor_feature", {
id,
feature: name,
});
Object.assign(
feature.value,
await invoke<Reply>("get_monitor_feature", {
id,
feature: name,
}),
);
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ const colors = reactive<Colors>({});
watchThrottled(
() => panelState.focused,
async () => {
Object.assign(colors, await invoke<Colors>("get_accent_colors"));
for (const [name, color] of Object.entries(await invoke<Colors>("get_accent_colors"))) {
colors[name] = Object.assign(colors[name] ?? {}, color);
}
},
{ throttle: 1000, immediate: true },
);
Expand Down

0 comments on commit 19b192e

Please sign in to comment.