mirror of
https://github.com/CharaChorder/DeviceManager.git
synced 2026-01-11 12:32:55 +00:00
refactor: use standard prettier formatting
This commit is contained in:
@@ -1,25 +1,27 @@
|
||||
import {get, writable} from "svelte/store"
|
||||
import { get, writable } from "svelte/store";
|
||||
|
||||
export const osLayout = writable<Map<string, string>>(new Map())
|
||||
export const osLayout = writable<Map<string, string>>(new Map());
|
||||
|
||||
async function updateLayout() {
|
||||
const layout: Map<string, string> = await (navigator as any).keyboard.getLayoutMap()
|
||||
const currentLayout = get(osLayout)
|
||||
const layout: Map<string, string> = await (
|
||||
navigator as any
|
||||
).keyboard.getLayoutMap();
|
||||
const currentLayout = get(osLayout);
|
||||
if (
|
||||
layout.size !== currentLayout.size ||
|
||||
[...layout.keys()].some(key => layout.get(key) !== currentLayout.get(key))
|
||||
[...layout.keys()].some((key) => layout.get(key) !== currentLayout.get(key))
|
||||
) {
|
||||
osLayout.set(layout)
|
||||
osLayout.set(layout);
|
||||
}
|
||||
}
|
||||
|
||||
export function runLayoutDetection(): () => void {
|
||||
if ("keyboard" in navigator) {
|
||||
updateLayout()
|
||||
const timer = setInterval(updateLayout, 5000)
|
||||
return () => clearInterval(timer)
|
||||
updateLayout();
|
||||
const timer = setInterval(updateLayout, 5000);
|
||||
return () => clearInterval(timer);
|
||||
} else {
|
||||
console.warn("Keyboard API not supported")
|
||||
return () => {}
|
||||
console.warn("Keyboard API not supported");
|
||||
return () => {};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user