From 875d1d778c8b279091f41b7bbf9390466fa5cbe6 Mon Sep 17 00:00:00 2001 From: John Costa Date: Sat, 3 May 2025 12:43:47 +0100 Subject: [PATCH] chore: cleaning up code to allow all platforms to co-exist --- frontend/src-tauri/src/lib.rs | 4 +-- frontend/src/App.tsx | 41 +++++-------------------- frontend/src/Search.tsx | 19 +++++++++++- frontend/src/components/ImageViewer.tsx | 15 --------- 4 files changed, 27 insertions(+), 52 deletions(-) diff --git a/frontend/src-tauri/src/lib.rs b/frontend/src-tauri/src/lib.rs index a244e3c..5c2eead 100644 --- a/frontend/src-tauri/src/lib.rs +++ b/frontend/src-tauri/src/lib.rs @@ -37,11 +37,9 @@ pub fn desktop() { shortcut::unregister_screenshot_shortcut, shortcut::get_current_screenshot_shortcut, ]) - // .manage(watcher_state) - // .invoke_handler(tauri::generate_handler![commands::handle_selected_folder,]) .setup(|app| { setup_window(app)?; - // shortcut::enable_shortcut(app); + shortcut::enable_shortcut(app); Ok(()) }) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index d0217b8..4c9d308 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,14 +1,12 @@ import { Route, Router } from "@solidjs/router"; import { listen } from "@tauri-apps/api/event"; -import { createEffect, createSignal, onCleanup, Show } from "solid-js"; +import { createEffect, onCleanup } from "solid-js"; import { Login } from "./Login"; import { ProtectedRoute } from "./ProtectedRoute"; import { Search } from "./Search"; import { Settings } from "./Settings"; -import { ImageViewer } from "./components/ImageViewer"; -import type { sendImage } from "./network"; -import { ImageStatus } from "./components/image-status/ImageStatus"; -import { invoke, type PluginListener } from "@tauri-apps/api/core"; +import { sendImageFile } from "./network"; +import type { PluginListener } from "@tauri-apps/api/core"; import { SearchImageContextProvider } from "./contexts/SearchImageContext"; import { platform } from "@tauri-apps/plugin-os"; import { @@ -20,11 +18,6 @@ import { readFile } from "@tauri-apps/plugin-fs"; const currentPlatform = platform(); export const App = () => { - const [processingImage, setProcessingImage] = - createSignal>>(); - - const [file, setFile] = createSignal(); - createEffect(() => { // TODO: Don't use window.location.href const unlisten = listen("focus-search", () => { @@ -37,8 +30,7 @@ export const App = () => { }); createEffect(() => { - if (currentPlatform !== "ios" && currentPlatform !== "android") { - console.log("not correct platform"); + if (currentPlatform !== "android") { return; } @@ -53,13 +45,11 @@ export const App = () => { }, ); - console.log(intent); + const f = new File([contents], intent.name ?? "no-name", { + type: intent.content_type, + }); - setFile( - new File([contents], intent.name ?? "no-name", { - type: intent.content_type, - }), - ); + sendImageFile(f.name, f); }, ); }; @@ -69,23 +59,8 @@ export const App = () => { }; }); - const onTakeScreenshot = () => { - invoke("take_screenshot"); - }; - return ( - - - -

{file()?.name}

- - diff --git a/frontend/src/Search.tsx b/frontend/src/Search.tsx index 4b25edd..3a342f2 100644 --- a/frontend/src/Search.tsx +++ b/frontend/src/Search.tsx @@ -14,8 +14,12 @@ import { SearchCard } from "./components/search-card/SearchCard"; import { invoke } from "@tauri-apps/api/core"; import { ItemModal } from "./components/item-modal/ItemModal"; import type { Shortcut } from "./components/shortcuts/hooks/useShortcutEditor"; -import type { UserImage } from "./network"; +import type { sendImage, UserImage } from "./network"; import { useSearchImageContext } from "./contexts/SearchImageContext"; +import { platform } from "@tauri-apps/plugin-os"; +import { ImageStatus } from "./components/image-status/ImageStatus"; + +const currentPlatform = platform(); export const Search = () => { const [searchResults, setSearchResults] = createSignal([]); @@ -24,6 +28,9 @@ export const Search = () => { null, ); + const [processingImage, setProcessingImage] = + createSignal>>(); + const { images } = useSearchImageContext(); let fuze = new Fuse(images() ?? [], { @@ -172,6 +179,16 @@ export const Search = () => { onClose={() => setSelectedItem(null)} /> )} + + + + + ); }; diff --git a/frontend/src/components/ImageViewer.tsx b/frontend/src/components/ImageViewer.tsx index 447a80c..edb5144 100644 --- a/frontend/src/components/ImageViewer.tsx +++ b/frontend/src/components/ImageViewer.tsx @@ -38,19 +38,4 @@ export const ImageViewer: Component = (props) => { }); return null; - - // return ( - //
- // {latestImage() && ( - //
- //

Latest Processed Image:

- // Latest processed - //
- // )} - //
- // ); };