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::unregister_screenshot_shortcut,
|
||||||
shortcut::get_current_screenshot_shortcut,
|
shortcut::get_current_screenshot_shortcut,
|
||||||
])
|
])
|
||||||
// .manage(watcher_state)
|
|
||||||
// .invoke_handler(tauri::generate_handler![commands::handle_selected_folder,])
|
|
||||||
.setup(|app| {
|
.setup(|app| {
|
||||||
setup_window(app)?;
|
setup_window(app)?;
|
||||||
// shortcut::enable_shortcut(app);
|
shortcut::enable_shortcut(app);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
import { Route, Router } from "@solidjs/router";
|
import { Route, Router } from "@solidjs/router";
|
||||||
import { listen } from "@tauri-apps/api/event";
|
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 { Login } from "./Login";
|
||||||
import { ProtectedRoute } from "./ProtectedRoute";
|
import { ProtectedRoute } from "./ProtectedRoute";
|
||||||
import { Search } from "./Search";
|
import { Search } from "./Search";
|
||||||
import { Settings } from "./Settings";
|
import { Settings } from "./Settings";
|
||||||
import { ImageViewer } from "./components/ImageViewer";
|
import { sendImageFile } from "./network";
|
||||||
import type { sendImage } from "./network";
|
import type { PluginListener } from "@tauri-apps/api/core";
|
||||||
import { ImageStatus } from "./components/image-status/ImageStatus";
|
|
||||||
import { invoke, type PluginListener } from "@tauri-apps/api/core";
|
|
||||||
import { SearchImageContextProvider } from "./contexts/SearchImageContext";
|
import { SearchImageContextProvider } from "./contexts/SearchImageContext";
|
||||||
import { platform } from "@tauri-apps/plugin-os";
|
import { platform } from "@tauri-apps/plugin-os";
|
||||||
import {
|
import {
|
||||||
@ -20,11 +18,6 @@ import { readFile } from "@tauri-apps/plugin-fs";
|
|||||||
const currentPlatform = platform();
|
const currentPlatform = platform();
|
||||||
|
|
||||||
export const App = () => {
|
export const App = () => {
|
||||||
const [processingImage, setProcessingImage] =
|
|
||||||
createSignal<Awaited<ReturnType<typeof sendImage>>>();
|
|
||||||
|
|
||||||
const [file, setFile] = createSignal<File>();
|
|
||||||
|
|
||||||
createEffect(() => {
|
createEffect(() => {
|
||||||
// TODO: Don't use window.location.href
|
// TODO: Don't use window.location.href
|
||||||
const unlisten = listen("focus-search", () => {
|
const unlisten = listen("focus-search", () => {
|
||||||
@ -37,8 +30,7 @@ export const App = () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
createEffect(() => {
|
createEffect(() => {
|
||||||
if (currentPlatform !== "ios" && currentPlatform !== "android") {
|
if (currentPlatform !== "android") {
|
||||||
console.log("not correct platform");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,13 +45,11 @@ export const App = () => {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log(intent);
|
const f = new File([contents], intent.name ?? "no-name", {
|
||||||
|
|
||||||
setFile(
|
|
||||||
new File([contents], intent.name ?? "no-name", {
|
|
||||||
type: intent.content_type,
|
type: intent.content_type,
|
||||||
}),
|
});
|
||||||
);
|
|
||||||
|
sendImageFile(f.name, f);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@ -69,23 +59,8 @@ export const App = () => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
const onTakeScreenshot = () => {
|
|
||||||
invoke("take_screenshot");
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SearchImageContextProvider>
|
<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>
|
<Router>
|
||||||
<Route path="/login" component={Login} />
|
<Route path="/login" component={Login} />
|
||||||
|
|
||||||
|
@ -14,8 +14,12 @@ import { SearchCard } from "./components/search-card/SearchCard";
|
|||||||
import { invoke } from "@tauri-apps/api/core";
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
import { ItemModal } from "./components/item-modal/ItemModal";
|
import { ItemModal } from "./components/item-modal/ItemModal";
|
||||||
import type { Shortcut } from "./components/shortcuts/hooks/useShortcutEditor";
|
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 { useSearchImageContext } from "./contexts/SearchImageContext";
|
||||||
|
import { platform } from "@tauri-apps/plugin-os";
|
||||||
|
import { ImageStatus } from "./components/image-status/ImageStatus";
|
||||||
|
|
||||||
|
const currentPlatform = platform();
|
||||||
|
|
||||||
export const Search = () => {
|
export const Search = () => {
|
||||||
const [searchResults, setSearchResults] = createSignal<UserImage[]>([]);
|
const [searchResults, setSearchResults] = createSignal<UserImage[]>([]);
|
||||||
@ -24,6 +28,9 @@ export const Search = () => {
|
|||||||
null,
|
null,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const [processingImage, setProcessingImage] =
|
||||||
|
createSignal<Awaited<ReturnType<typeof sendImage>>>();
|
||||||
|
|
||||||
const { images } = useSearchImageContext();
|
const { images } = useSearchImageContext();
|
||||||
|
|
||||||
let fuze = new Fuse<UserImage>(images() ?? [], {
|
let fuze = new Fuse<UserImage>(images() ?? [], {
|
||||||
@ -172,6 +179,16 @@ export const Search = () => {
|
|||||||
onClose={() => setSelectedItem(null)}
|
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 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