Files
dbgate/packages/web/src/utility/openArchiveFolder.ts
2021-12-22 10:16:44 +01:00

22 lines
750 B
TypeScript

import { get } from 'svelte/store';
import getElectron from './getElectron';
import { currentArchive, extensions, selectedWidget } from '../stores';
import axiosInstance from '../utility/axiosInstance';
import { showSnackbarSuccess } from './snackbar';
import { apiCall } from './api';
export async function openArchiveFolder() {
const electron = getElectron();
const ext = get(extensions);
const filePaths = await electron.showOpenDialog({
properties: ['openDirectory'],
});
const linkedFolder = filePaths && filePaths[0];
if (!linkedFolder) return;
const resp = await apiCall('archive/create-link', { linkedFolder });
currentArchive.set(resp);
selectedWidget.set('archive');
showSnackbarSuccess(`Created link ${resp}`);
}