diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index bde8a6a..569b1b6 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -13,9 +13,11 @@ import { WithNotifications } from "@contexts/Notifications"; import { ProtectedRoute } from "@components/protected-route"; import { AppWrapper } from "@components/app-wrapper"; import { WithTopbarAndDock } from "@components/app-wrapper/with-topbar-and-dock"; +import { onSendImage } from "@contexts/send-image"; export const App = () => { onAndroidMount(); + onSendImage(); return ( diff --git a/frontend/src/contexts/send-image.ts b/frontend/src/contexts/send-image.ts new file mode 100644 index 0000000..e6f083e --- /dev/null +++ b/frontend/src/contexts/send-image.ts @@ -0,0 +1,32 @@ +import { createEffect } from "solid-js"; +import { listen } from "@tauri-apps/api/event"; +import { getCurrentWindow } from "@tauri-apps/api/window"; +import { sendImage } from "@network/index"; + +export const onSendImage = () => { + let sentImage = ""; + + createEffect(async () => { + // Listen for PNG processing events + const unlisten = listen("png-processed", async (event) => { + const base64Data = event.payload as string; + + if (base64Data === sentImage) { + return; + } + + sentImage = base64Data; + + const appWindow = getCurrentWindow(); + + appWindow.show(); + appWindow.setFocus(); + + await sendImage("test-image.png", base64Data); + }); + + return () => { + unlisten.then((fn) => fn()); // Cleanup listener + }; + }); +};