mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-18 15:33:52 +01:00
32 lines
1.0 KiB
TypeScript
32 lines
1.0 KiB
TypeScript
import { useFastMutation } from './useFastMutation';
|
|
import { SettingsTab } from '../components/Settings/Settings';
|
|
import { trackEvent } from '../lib/analytics';
|
|
import { invokeCmd } from '../lib/tauri';
|
|
import { router } from '../main';
|
|
import { Route as SettingsRoute } from '../routes/workspaces/settings';
|
|
import { useActiveWorkspace } from './useActiveWorkspace';
|
|
|
|
export function useOpenSettings(tab = SettingsTab.General) {
|
|
const workspace = useActiveWorkspace();
|
|
|
|
return useFastMutation({
|
|
mutationKey: ['open_settings'],
|
|
mutationFn: async () => {
|
|
if (workspace == null) return;
|
|
|
|
trackEvent('dialog', 'show', { id: 'settings', tab: `${tab}` });
|
|
const location = router.buildLocation({
|
|
to: SettingsRoute.fullPath,
|
|
params: { workspaceId: workspace.id },
|
|
search: { tab },
|
|
});
|
|
await invokeCmd('cmd_new_child_window', {
|
|
url: location,
|
|
label: 'settings',
|
|
title: 'Yaak Settings',
|
|
innerSize: [600, 550],
|
|
});
|
|
},
|
|
});
|
|
}
|