improve types

This commit is contained in:
Anton Bracke
2022-02-22 12:02:56 +01:00
parent d03544c839
commit 71c8e32b2f
16 changed files with 105 additions and 121 deletions
+20 -6
View File
@@ -1,19 +1,33 @@
<script lang="ts">
import { onMount } from "svelte";
import { writable } from "svelte/store";
import { writable, get } from "svelte/store";
import ToggleSwitch from "~/lib/ToggleSwitch.svelte";
import InputField from "~/lib/InputField.svelte";
import KeyRecord from "~/lib/KeyRecord.svelte";
import { api, SettingsData } from "../lib/ipc";
const shortCuts = writable<Record<string, string> | undefined>({});
type ShortCuts = Record<"mute_toggle" | "camera_toggle", string>;
onMount(async () => {
shortCuts.set(await window?.WorkAdventureDesktopApi?.getShortcuts());
const shortCuts = writable<ShortCuts>({
mute_toggle: "",
camera_toggle: "",
});
async function saveShortcut(key: string, value: string) {
await window?.WorkAdventureDesktopApi?.saveShortcut(key, value);
onMount(async () => {
const newShortCuts = await api.getSettings()?.["shortcuts"];
shortCuts.set({
...get(shortCuts),
...newShortCuts,
});
});
async function saveShortcut(key: keyof SettingsData['shortcuts'], value: string) {
shortCuts.update((shortCuts) => ({
...shortCuts,
[key]: value,
}));
await api.saveSetting('shortcuts', get(shortCuts));
}
</script>