mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-18 23:44:12 +01:00
Try sandboxing again
This commit is contained in:
@@ -1,17 +1,12 @@
|
||||
import { useMutation } from '@tanstack/react-query';
|
||||
import { invoke } from '@tauri-apps/api';
|
||||
import type { SaveDialogOptions } from '@tauri-apps/api/dialog';
|
||||
import { save } from '@tauri-apps/api/dialog';
|
||||
import { useActiveWorkspaceId } from './useActiveWorkspaceId';
|
||||
import slugify from 'slugify';
|
||||
import { useActiveWorkspace } from './useActiveWorkspace';
|
||||
import { useAlert } from './useAlert';
|
||||
|
||||
const saveArgs: SaveDialogOptions = {
|
||||
title: 'Export Data',
|
||||
defaultPath: 'yaak-export.json',
|
||||
};
|
||||
|
||||
export function useExportData() {
|
||||
const workspaceId = useActiveWorkspaceId();
|
||||
const workspace = useActiveWorkspace();
|
||||
const alert = useAlert();
|
||||
|
||||
return useMutation({
|
||||
@@ -19,12 +14,18 @@ export function useExportData() {
|
||||
alert({ title: 'Export Failed', body: err });
|
||||
},
|
||||
mutationFn: async () => {
|
||||
const exportPath = await save(saveArgs);
|
||||
if (workspace == null) return;
|
||||
|
||||
const workspaceSlug = slugify(workspace.name, { lower: true });
|
||||
const exportPath = await save({
|
||||
title: 'Export Data',
|
||||
defaultPath: `yaak.${workspaceSlug}.json`,
|
||||
});
|
||||
if (exportPath == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
await invoke('export_data', { workspaceId, exportPath });
|
||||
await invoke('export_data', { workspaceId: workspace.id, exportPath });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user