diff --git a/src/components/modals/servermodals.tsx b/src/components/modals/servermodals.tsx index 0533936..b0bfaae 100644 --- a/src/components/modals/servermodals.tsx +++ b/src/components/modals/servermodals.tsx @@ -105,12 +105,13 @@ const ServerModals = React.forwardRef(functio useEffect(() => { if (TAURI) { - const listenResult = appWindow.listen("tauri://file-drop", (event) => { - const files = event.payload.filter((path) => path.toLowerCase().endsWith(".torrent")); - if (files.length > 0) enqueue(files); + const dropResult = appWindow.onDragDropEvent((event) => { + if (event.payload.type === "drop") { + const files = event.payload.paths.filter((path) => path.toLowerCase().endsWith(".torrent")); + if (files.length > 0) enqueue(files); + } }); - - return () => { void listenResult.then((unlisten) => { unlisten(); }); }; + return () => { void dropResult.then((unlisten) => { unlisten(); }); }; } else { document.ondragover = (e) => { e.preventDefault(); }; document.ondrop = (event) => { diff --git a/src/taurishim.ts b/src/taurishim.ts index c352fdf..1498f9d 100644 --- a/src/taurishim.ts +++ b/src/taurishim.ts @@ -18,6 +18,7 @@ import type { EventCallback } from "@tauri-apps/api/event"; import type { CloseRequestedEvent, PhysicalPosition, PhysicalSize } from "@tauri-apps/api/window"; +import type { DragDropEvent } from "@tauri-apps/api/webview"; export const TAURI = Object.prototype.hasOwnProperty.call(window, "__TAURI__"); const realAppWindow = TAURI ? (await import(/* webpackMode: "lazy-once" */ "@tauri-apps/api/window")).getCurrentWindow() : undefined; @@ -36,7 +37,8 @@ export const appWindow = { listen: async (event: string, handler: EventCallback) => await realAppWindow?.listen(event, handler) ?? (() => { }), once: async (event: string, handler: EventCallback) => await realAppWindow?.once(event, handler), - + onDragDropEvent: async (handler: EventCallback) => + await realAppWindow?.onDragDropEvent(handler) ?? (() => { }), onCloseRequested: async (handler: (event: CloseRequestedEvent) => void | Promise) => await realAppWindow?.onCloseRequested(handler), onFocusChanged: async (handler: EventCallback) =>