feat: add bun.lockb and refactor App.tsx for improved event handling
This commit is contained in:
BIN
frontend/bun.lockb
Executable file
BIN
frontend/bun.lockb
Executable file
Binary file not shown.
@ -1,21 +1,21 @@
|
|||||||
import { Route, Router } from "@solidjs/router";
|
import { Route, Router } from "@solidjs/router";
|
||||||
|
import type { PluginListener } from "@tauri-apps/api/core";
|
||||||
import { listen } from "@tauri-apps/api/event";
|
import { listen } from "@tauri-apps/api/event";
|
||||||
|
import { readFile } from "@tauri-apps/plugin-fs";
|
||||||
|
import { platform } from "@tauri-apps/plugin-os";
|
||||||
import { createEffect, createSignal, onCleanup } from "solid-js";
|
import { createEffect, createSignal, onCleanup } from "solid-js";
|
||||||
|
import {
|
||||||
|
type ShareEvent,
|
||||||
|
listenForShareEvents,
|
||||||
|
} from "tauri-plugin-sharetarget-api";
|
||||||
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 { sendImage, sendImageFile } from "./network";
|
|
||||||
import type { PluginListener } from "@tauri-apps/api/core";
|
|
||||||
import { SearchImageContextProvider } from "./contexts/SearchImageContext";
|
|
||||||
import { platform } from "@tauri-apps/plugin-os";
|
|
||||||
import {
|
|
||||||
listenForShareEvents,
|
|
||||||
type ShareEvent,
|
|
||||||
} from "tauri-plugin-sharetarget-api";
|
|
||||||
import { readFile } from "@tauri-apps/plugin-fs";
|
|
||||||
import { ImageViewer } from "./components/ImageViewer";
|
import { ImageViewer } from "./components/ImageViewer";
|
||||||
import { ImageStatus } from "./components/image-status/ImageStatus";
|
import { ImageStatus } from "./components/image-status/ImageStatus";
|
||||||
|
import { SearchImageContextProvider } from "./contexts/SearchImageContext";
|
||||||
|
import { type sendImage, sendImageFile } from "./network";
|
||||||
|
|
||||||
const currentPlatform = platform();
|
const currentPlatform = platform();
|
||||||
console.log("Current Platform: ", currentPlatform);
|
console.log("Current Platform: ", currentPlatform);
|
||||||
@ -32,40 +32,40 @@ export const App = () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
createEffect(() => {
|
// createEffect(() => {
|
||||||
if (currentPlatform !== "android") {
|
// if (currentPlatform !== "android") {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
let listener: PluginListener;
|
// let listener: PluginListener;
|
||||||
|
|
||||||
const setupListener = async () => {
|
// const setupListener = async () => {
|
||||||
console.log("Setting up listener");
|
// console.log("Setting up listener");
|
||||||
|
|
||||||
listener = await listenForShareEvents(
|
// listener = await listenForShareEvents(
|
||||||
async (intent: ShareEvent) => {
|
// async (intent: ShareEvent) => {
|
||||||
console.log(intent);
|
// console.log(intent);
|
||||||
const contents = await readFile(intent.stream ?? "").catch(
|
// const contents = await readFile(intent.stream ?? "").catch(
|
||||||
(error: Error) => {
|
// (error: Error) => {
|
||||||
console.warn("fetching shared content failed:");
|
// console.warn("fetching shared content failed:");
|
||||||
throw error;
|
// throw error;
|
||||||
},
|
// },
|
||||||
);
|
// );
|
||||||
|
|
||||||
const f = new File([contents], intent.name ?? "no-name", {
|
// const f = new File([contents], intent.name ?? "no-name", {
|
||||||
type: intent.content_type,
|
// type: intent.content_type,
|
||||||
});
|
// });
|
||||||
|
|
||||||
sendImageFile(f.name, f);
|
// sendImageFile(f.name, f);
|
||||||
},
|
// },
|
||||||
);
|
// );
|
||||||
};
|
// };
|
||||||
|
|
||||||
setupListener();
|
// setupListener();
|
||||||
return () => {
|
// return () => {
|
||||||
listener?.unregister();
|
// listener?.unregister();
|
||||||
};
|
// };
|
||||||
});
|
// });
|
||||||
|
|
||||||
const [processingImage, setProcessingImage] = createSignal<
|
const [processingImage, setProcessingImage] = createSignal<
|
||||||
Awaited<ReturnType<typeof sendImage>> | undefined
|
Awaited<ReturnType<typeof sendImage>> | undefined
|
||||||
|
Reference in New Issue
Block a user