From 7970e8670cf6adc96cbf217f8f2d24d1687b5f43 Mon Sep 17 00:00:00 2001 From: Dmytro Kondakov Date: Sun, 4 May 2025 14:06:35 +0200 Subject: [PATCH] refactor(App.tsx): re-enable event listener setup for Android platform --- frontend/src/App.tsx | 56 ++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 4bad0a6..80722b9 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -32,40 +32,40 @@ export const App = () => { }); }); - // createEffect(() => { - // if (currentPlatform !== "android") { - // return; - // } + createEffect(() => { + if (currentPlatform !== "android") { + return; + } - // let listener: PluginListener; + let listener: PluginListener; - // const setupListener = async () => { - // console.log("Setting up listener"); + const setupListener = async () => { + console.log("Setting up listener"); - // listener = await listenForShareEvents( - // async (intent: ShareEvent) => { - // console.log(intent); - // const contents = await readFile(intent.stream ?? "").catch( - // (error: Error) => { - // console.warn("fetching shared content failed:"); - // throw error; - // }, - // ); + listener = await listenForShareEvents( + async (intent: ShareEvent) => { + console.log(intent); + const contents = await readFile(intent.stream ?? "").catch( + (error: Error) => { + console.warn("fetching shared content failed:"); + throw error; + }, + ); - // const f = new File([contents], intent.name ?? "no-name", { - // type: intent.content_type, - // }); + const f = new File([contents], intent.name ?? "no-name", { + type: intent.content_type, + }); - // sendImageFile(f.name, f); - // }, - // ); - // }; + sendImageFile(f.name, f); + }, + ); + }; - // setupListener(); - // return () => { - // listener?.unregister(); - // }; - // }); + setupListener(); + return () => { + listener?.unregister(); + }; + }); const [processingImage, setProcessingImage] = createSignal< Awaited> | undefined