refactor: reorganize frontend code

This commit is contained in:
Ryan Walters
2025-08-20 02:19:12 -05:00
parent f90f377277
commit 3414880705
6 changed files with 78 additions and 72 deletions

View File

@@ -0,0 +1,24 @@
import { useEffect, useState } from "react";
import { getCurrentWebview } from "@tauri-apps/api/webview";
export function useDragDropPaths(): string[] {
const [paths, setPaths] = useState<string[]>([]);
useEffect(() => {
const unlistenPromise = getCurrentWebview().onDragDropEvent(
async ({ payload }) => {
if (payload.type === "enter") {
setPaths(payload.paths);
} else if (payload.type === "leave" || payload.type === "drop") {
setPaths([]);
}
},
);
return () => {
unlistenPromise.then((unlisten) => unlisten());
};
}, []);
return paths;
}