mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-24 10:21:15 +01:00
Context menu, logs in DevTools, export, tweaks
This commit is contained in:
31
src-web/hooks/useExportData.tsx
Normal file
31
src-web/hooks/useExportData.tsx
Normal file
@@ -0,0 +1,31 @@
|
||||
import { useMutation } from '@tanstack/react-query';
|
||||
import { invoke } from '@tauri-apps/api';
|
||||
import type { OpenDialogOptions } from '@tauri-apps/api/dialog';
|
||||
import { open } from '@tauri-apps/api/dialog';
|
||||
import { useActiveWorkspaceId } from './useActiveWorkspaceId';
|
||||
|
||||
const openArgs: OpenDialogOptions = {
|
||||
directory: true,
|
||||
multiple: false,
|
||||
title: 'Select Export Folder',
|
||||
};
|
||||
|
||||
export function useExportData() {
|
||||
const workspaceId = useActiveWorkspaceId();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async () => {
|
||||
const selected = await open(openArgs);
|
||||
if (selected == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
const rootDir = Array.isArray(selected) ? selected[0] : selected;
|
||||
if (rootDir == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
await invoke('export_data', { workspaceId, rootDir });
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user