mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-08-29 22:57:14 +02:00
Add a typed platform package to decouple the frontend from Tauri (#539)
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
0068be9ffc
commit
2383f06e71
@@ -1,5 +1,5 @@
|
||||
// Listen for settings changes, the re-compute theme
|
||||
import { listen } from "@tauri-apps/api/event";
|
||||
import { platform } from "@yaakapp-internal/platform";
|
||||
import type { ModelPayload } from "@yaakapp-internal/models";
|
||||
import { fireAndForget } from "./lib/fireAndForget";
|
||||
import { getSettings } from "./lib/settings";
|
||||
@@ -8,12 +8,12 @@ function setFontSizeOnDocument(fontSize: number) {
|
||||
document.documentElement.style.fontSize = `${fontSize}px`;
|
||||
}
|
||||
|
||||
listen<ModelPayload[]>("model_writes", async (event) => {
|
||||
for (const payload of event.payload) {
|
||||
platform.listen<ModelPayload[]>("model_writes", (payloads) => {
|
||||
for (const payload of payloads) {
|
||||
if (payload.change.type !== "upsert") continue;
|
||||
if (payload.model.model !== "settings") continue;
|
||||
setFontSizeOnDocument(payload.model.interfaceFontSize);
|
||||
}
|
||||
}).catch(console.error);
|
||||
});
|
||||
|
||||
fireAndForget(getSettings().then((settings) => setFontSizeOnDocument(settings.interfaceFontSize)));
|
||||
|
||||
Reference in New Issue
Block a user