Try sandboxing again

This commit is contained in:
Gregory Schier
2023-11-19 17:06:31 -08:00
parent 3c0edf06af
commit aff26fdd46
8 changed files with 34 additions and 25 deletions

View File

@@ -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 });
},
});
}