diff --git a/src/main/lib/window/resizer.ts b/src/main/lib/window/resizer.ts index c2064120..4956e075 100644 --- a/src/main/lib/window/resizer.ts +++ b/src/main/lib/window/resizer.ts @@ -1,6 +1,7 @@ import { orDefault } from "@shared/lib/rust-types/Optional"; import { Storage } from "@main/lib/storage/Storage"; import { BrowserWindow } from "electron"; +import { Router } from "@main/lib/route-pass/Router"; /** * Save window dimensions so that it can be opened the same size it was closed @@ -13,6 +14,14 @@ export default function trackBounds(window: BrowserWindow): void { const bounds = window.getBounds(); settings.write("window.width", bounds.width); settings.write("window.height", bounds.height); + + // Send a notice about the window resize + Router.dispatch(window, "notify", { + variant: "neutral", + title: "Window Resized", + description: `New dimensions: ${bounds.width}x${bounds.height}`, + icon: "maximize-icon" + }); }); window.on("unmaximize", () => { diff --git a/src/renderer/src/components/notice/NoticeContainer.tsx b/src/renderer/src/components/notice/NoticeContainer.tsx index eb35d4b4..95007813 100644 --- a/src/renderer/src/components/notice/NoticeContainer.tsx +++ b/src/renderer/src/components/notice/NoticeContainer.tsx @@ -4,7 +4,8 @@ import { TokenNamespace } from "@shared/lib/tungsten/token"; import Notice, { IconNoticeType } from "./Notice"; import { For, createSignal } from "solid-js"; import { createStore } from "solid-js/store"; - +import { MaximizeIcon, XIcon } from "lucide-solid"; +import { NoticeTypeIconMap } from "@shared/types/common.types"; const [notices, setNotices] = createStore([]); const namespace = new TokenNamespace(); const [isPaused, setIsPaused] = createSignal(false); @@ -32,8 +33,23 @@ function hideNotice(id: string | undefined): Result { export { notices, isPaused, setIsPaused }; -window.api.listen("notify", (n) => { - addNotice(n); +window.api.listen("notify", (n: NoticeTypeIconMap) => { + const noticeParams: IconNoticeType = { + id: n.id, + variant: n.variant, + title: n.title, + description: n.description, + }; + + switch (n.icon) { + case "maximize-icon": + noticeParams.icon = ; + break; + case "X-icon": + noticeParams.icon = ; + } + + addNotice(noticeParams); }); const NoticeContainer = () => { diff --git a/src/shared/types/common.types.ts b/src/shared/types/common.types.ts index 6cbe6d9a..e0b7f11f 100644 --- a/src/shared/types/common.types.ts +++ b/src/shared/types/common.types.ts @@ -243,3 +243,8 @@ export type NoticeType = { title?: string; description?: string; }; + +export type NoticeTypeIconMap = NoticeType & { + icon?: "maximize-icon" | "X-icon"; +}; + diff --git a/src/shared/types/router.types.ts b/src/shared/types/router.types.ts index fad09dd6..d81950a7 100644 --- a/src/shared/types/router.types.ts +++ b/src/shared/types/router.types.ts @@ -13,7 +13,7 @@ import type { Song, SongsQueryPayload, LoadingSceneUpdate, - NoticeType, + NoticeTypeIconMap, Scenes, } from "./common.types"; import type { SearchQuery } from "./search-parser.types"; @@ -93,5 +93,5 @@ export type ListenAPI = { "window::maximizeChange": (maximized: boolean) => void; - notify: (notice: NoticeType) => void; + notify: (notice: NoticeTypeIconMap) => void; };