fix: re-adding send image listener
wip fix: re-adding send image listener
This commit is contained in:
@ -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 (
|
||||
<SearchImageContextProvider>
|
||||
|
32
frontend/src/contexts/send-image.ts
Normal file
32
frontend/src/contexts/send-image.ts
Normal file
@ -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
|
||||
};
|
||||
});
|
||||
};
|
Reference in New Issue
Block a user