Skip to content

Commit

Permalink
Fix WindowState type inconsistency #4
Browse files Browse the repository at this point in the history
  • Loading branch information
Lev Z Király authored and Lev Z Király committed Nov 22, 2023
1 parent 7dac138 commit 9ad1f82
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions stores/use-windows-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ const WindowState = z.object({
title: z.string(),
params: z.unknown(),
});
type WindowStateInferred = z.infer<typeof WindowState>;

export const useWindowsStore = defineStore("windows", () => {
const registry = ref<WindowRegistry>(new Map());
Expand All @@ -124,9 +125,9 @@ export const useWindowsStore = defineStore("windows", () => {
return;
}

let windowStates: Array<WindowState>;
let windowStates: Array<WindowStateInferred>;
try {
windowStates = JSON.parse(route.query.w as string) as Array<WindowState>;
windowStates = JSON.parse(route.query.w as string) as Array<WindowStateInferred>;
} catch (e) {
toasts.addToast({ title: "Error: JSON parse failed", description: e.message });
await initializeScreen();
Expand Down Expand Up @@ -264,7 +265,7 @@ export const useWindowsStore = defineStore("windows", () => {
});

function serializeWindowStates() {
const windowStates: Array<WindowState> = [];
const windowStates: Array<WindowStateInferred> = [];
registry.value.forEach((w) => {
windowStates.push({
x: w.winbox.x as number,
Expand All @@ -274,7 +275,7 @@ export const useWindowsStore = defineStore("windows", () => {
kind: w.kind,
title: w.winbox.title,
params: w.params,
} as z.infer<typeof WindowState>);
} as WindowStateInferred);
});
console.log(JSON.stringify(windowStates));
return windowStates;
Expand Down

0 comments on commit 9ad1f82

Please sign in to comment.