wip: showing the file name
This commit is contained in:
@ -8,9 +8,14 @@ import { Settings } from "./Settings";
|
|||||||
import { ImageViewer } from "./components/ImageViewer";
|
import { ImageViewer } from "./components/ImageViewer";
|
||||||
import type { sendImage } from "./network";
|
import type { sendImage } from "./network";
|
||||||
import { ImageStatus } from "./components/image-status/ImageStatus";
|
import { ImageStatus } from "./components/image-status/ImageStatus";
|
||||||
import { invoke } from "@tauri-apps/api/core";
|
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 {
|
||||||
|
listenForShareEvents,
|
||||||
|
type ShareEvent,
|
||||||
|
} from "tauri-plugin-sharetarget-api";
|
||||||
|
import { readFile } from "@tauri-apps/plugin-fs";
|
||||||
|
|
||||||
const currentPlatform = platform();
|
const currentPlatform = platform();
|
||||||
|
|
||||||
@ -18,6 +23,8 @@ export const App = () => {
|
|||||||
const [processingImage, setProcessingImage] =
|
const [processingImage, setProcessingImage] =
|
||||||
createSignal<Awaited<ReturnType<typeof sendImage>>>();
|
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", () => {
|
||||||
@ -29,31 +36,34 @@ export const App = () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// createEffect(() => {
|
createEffect(() => {
|
||||||
// let listener: PluginListener;
|
if (currentPlatform !== "ios" && currentPlatform !== "android") {
|
||||||
// const setupListener = async () => {
|
return;
|
||||||
// listener = await listenForShareEvents(
|
}
|
||||||
// async (intent: ShareEvent) => {
|
|
||||||
// const contents = await readFile(intent.stream ?? "").catch(
|
let listener: PluginListener;
|
||||||
// (error: Error) => {
|
const setupListener = async () => {
|
||||||
// console.warn("fetching shared content failed:");
|
listener = await listenForShareEvents(
|
||||||
// throw error;
|
async (intent: ShareEvent) => {
|
||||||
// },
|
const contents = await readFile(intent.stream ?? "").catch(
|
||||||
// );
|
(error: Error) => {
|
||||||
// setFile(
|
console.warn("fetching shared content failed:");
|
||||||
// new File([contents], intent.name ?? "no-name", {
|
throw error;
|
||||||
// type: intent.content_type,
|
},
|
||||||
// }),
|
);
|
||||||
// );
|
setFile(
|
||||||
// setLogs((l) => [...l, intent.uri]);
|
new File([contents], intent.name ?? "no-name", {
|
||||||
// },
|
type: intent.content_type,
|
||||||
// );
|
}),
|
||||||
// };
|
);
|
||||||
// setupListener();
|
},
|
||||||
// return () => {
|
);
|
||||||
// listener?.unregister();
|
};
|
||||||
// };
|
setupListener();
|
||||||
// });
|
return () => {
|
||||||
|
listener?.unregister();
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
const onTakeScreenshot = () => {
|
const onTakeScreenshot = () => {
|
||||||
invoke("take_screenshot");
|
invoke("take_screenshot");
|
||||||
@ -66,6 +76,7 @@ export const App = () => {
|
|||||||
Take Screenshot [wayland :(]
|
Take Screenshot [wayland :(]
|
||||||
</button>
|
</button>
|
||||||
</Show>
|
</Show>
|
||||||
|
<p>{file()?.name}</p>
|
||||||
<ImageViewer onSendImage={setProcessingImage} />
|
<ImageViewer onSendImage={setProcessingImage} />
|
||||||
<ImageStatus
|
<ImageStatus
|
||||||
processingImage={processingImage}
|
processingImage={processingImage}
|
||||||
|
Reference in New Issue
Block a user