From 251d65a925f7623a33b3909f5f1b235cbd90b74c Mon Sep 17 00:00:00 2001 From: jayzcoder <32261474+jayzcoder@users.noreply.github.com> Date: Sun, 11 Jan 2026 23:26:19 +0800 Subject: [PATCH 1/2] fix: `tauri://file-drop` is no longer supported in the new version; use `onDragDropEvent`. --- src/components/modals/servermodals.tsx | 11 ++++++----- src/taurishim.ts | 4 +++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/components/modals/servermodals.tsx b/src/components/modals/servermodals.tsx index 0533936a..1617d8b5 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 c352fdf3..b6502a06 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 {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) => From c2caf12c795d40cb5ea034875bb8fbb3ac9deb44 Mon Sep 17 00:00:00 2001 From: jay Date: Mon, 12 Jan 2026 12:46:57 +0800 Subject: [PATCH 2/2] fix the eslint warnings. --- src/components/modals/servermodals.tsx | 2 +- src/taurishim.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/modals/servermodals.tsx b/src/components/modals/servermodals.tsx index 1617d8b5..b0bfaaea 100644 --- a/src/components/modals/servermodals.tsx +++ b/src/components/modals/servermodals.tsx @@ -106,7 +106,7 @@ const ServerModals = React.forwardRef(functio useEffect(() => { if (TAURI) { const dropResult = appWindow.onDragDropEvent((event) => { - if (event.payload.type === 'drop') { + if (event.payload.type === "drop") { const files = event.payload.paths.filter((path) => path.toLowerCase().endsWith(".torrent")); if (files.length > 0) enqueue(files); } diff --git a/src/taurishim.ts b/src/taurishim.ts index b6502a06..1498f9d3 100644 --- a/src/taurishim.ts +++ b/src/taurishim.ts @@ -18,7 +18,7 @@ import type { EventCallback } from "@tauri-apps/api/event"; import type { CloseRequestedEvent, PhysicalPosition, PhysicalSize } from "@tauri-apps/api/window"; -import {DragDropEvent} from "@tauri-apps/api/webview"; +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;