Skip to content

Commit

Permalink
Fix type issues in window store #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 9ad1f82 commit c01d892
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions stores/use-windows-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { z } from "zod";

import type { QueryDescription } from "@/lib/api-client";
import * as arrange from "@/utils/window-arrangement";

import { useToastsStore } from "./use-toasts-store";

interface WindowItemBase {
Expand Down Expand Up @@ -129,14 +130,18 @@ export const useWindowsStore = defineStore("windows", () => {
try {
windowStates = JSON.parse(route.query.w as string) as Array<WindowStateInferred>;
} catch (e) {
toasts.addToast({ title: "Error: JSON parse failed", description: e.message });
toasts.addToast({
title: "RestoreState Error: JSON parse failed",
description: e instanceof Error ? e.message : "Unknown error, check console",
});
console.error(e);
await initializeScreen();
return;
}

if (!Array.isArray(windowStates)) {
toasts.addToast({
title: "Error: Window list is not array",
title: "RestoreState Error: Window list is not array",
description: "Window list parameter must be an array",
});
await initializeScreen();
Expand All @@ -150,15 +155,18 @@ export const useWindowsStore = defineStore("windows", () => {
WindowState.parse(w);
addWindow({
title: w.title,
kind: w.kind,
kind: w.kind as WindowItemKind,
params: w.params,
x: w.x,
y: w.y,
height: w.height,
width: w.width,
});
} catch (e) {
toasts.addToast({ title: "Error: WindowState parse failed", description: e.message });
toasts.addToast({
title: "RestoreState Error: WindowState parse failed",
description: e instanceof Error ? e.message : "Unknown error, check console",
});
console.error(e);
}
});
Expand Down

0 comments on commit c01d892

Please sign in to comment.