chore: cleaning up code to allow all platforms to co-exist
This commit is contained in:
@ -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(())
|
||||
})
|
||||
|
@ -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<Awaited<ReturnType<typeof sendImage>>>();
|
||||
|
||||
const [file, setFile] = createSignal<File>();
|
||||
|
||||
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);
|
||||
|
||||
setFile(
|
||||
new File([contents], intent.name ?? "no-name", {
|
||||
const f = 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 (
|
||||
<SearchImageContextProvider>
|
||||
<Show when={currentPlatform === "linux"}>
|
||||
<button type="button" onClick={onTakeScreenshot}>
|
||||
Take Screenshot [wayland :(]
|
||||
</button>
|
||||
</Show>
|
||||
<p>{file()?.name}</p>
|
||||
<ImageViewer onSendImage={setProcessingImage} />
|
||||
<ImageStatus
|
||||
processingImage={processingImage}
|
||||
onSetProcessingImage={setProcessingImage}
|
||||
/>
|
||||
<Router>
|
||||
<Route path="/login" component={Login} />
|
||||
|
||||
|
@ -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<UserImage[]>([]);
|
||||
@ -24,6 +28,9 @@ export const Search = () => {
|
||||
null,
|
||||
);
|
||||
|
||||
const [processingImage, setProcessingImage] =
|
||||
createSignal<Awaited<ReturnType<typeof sendImage>>>();
|
||||
|
||||
const { images } = useSearchImageContext();
|
||||
|
||||
let fuze = new Fuse<UserImage>(images() ?? [], {
|
||||
@ -172,6 +179,16 @@ export const Search = () => {
|
||||
onClose={() => setSelectedItem(null)}
|
||||
/>
|
||||
)}
|
||||
|
||||
<Show when={currentPlatform === "linux"}>
|
||||
<button type="button" onClick={() => invoke("take_screenshot")}>
|
||||
Take Screenshot [wayland :(]
|
||||
</button>
|
||||
</Show>
|
||||
<ImageStatus
|
||||
processingImage={processingImage}
|
||||
onSetProcessingImage={setProcessingImage}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
@ -38,19 +38,4 @@ export const ImageViewer: Component<ImageViewerProps> = (props) => {
|
||||
});
|
||||
|
||||
return null;
|
||||
|
||||
// return (
|
||||
// <div class="fixed inset-0">
|
||||
// {latestImage() && (
|
||||
// <div class="mt-4">
|
||||
// <h3>Latest Processed Image:</h3>
|
||||
// <img
|
||||
// src={latestImage() || undefined}
|
||||
// alt="Latest processed"
|
||||
// class="max-w-md"
|
||||
// />
|
||||
// </div>
|
||||
// )}
|
||||
// </div>
|
||||
// );
|
||||
};
|
||||
|
Reference in New Issue
Block a user