mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-02 07:53:55 +03:00
chore: refactor menu subscription and event handling in components
This commit is contained in:
parent
d477c26930
commit
b5712d0b00
@ -15,8 +15,6 @@
|
||||
import ShareIssueModal from './ShareIssueModal.svelte';
|
||||
import { SETTINGS_CONTEXT, loadUserSettings } from '$lib/settings/userSettings';
|
||||
import { initTheme } from './user/theme';
|
||||
import { navigating } from '$app/stores';
|
||||
import { subscribe as menuSubscribe } from '$lib/menu';
|
||||
|
||||
export let data: LayoutData;
|
||||
const { projectService, cloud, user$ } = data;
|
||||
@ -32,18 +30,6 @@
|
||||
$: document.documentElement.style.fontSize = zoom + 'rem';
|
||||
$: userSettings.update((s) => ({ ...s, zoom: zoom }));
|
||||
|
||||
// listen for current project events
|
||||
let unsubscribeMenu = () => {};
|
||||
$: if ($navigating) {
|
||||
const fromProject = $navigating?.from?.params?.projectId;
|
||||
const toProject = $navigating?.to?.params?.projectId;
|
||||
const projectHasChanged = fromProject !== toProject;
|
||||
if (projectHasChanged && toProject) {
|
||||
unsubscribeMenu?.();
|
||||
unsubscribeMenu = menuSubscribe(toProject);
|
||||
}
|
||||
}
|
||||
|
||||
onMount(() =>
|
||||
unsubscribe(
|
||||
events.on('openNewProjectModal', async () =>
|
||||
|
@ -15,6 +15,7 @@
|
||||
import Button from '$lib/components/Button.svelte';
|
||||
import { syncToCloud } from '$lib/backend/cloud';
|
||||
import { handleMenuActions } from '$lib/backend/menu_actions';
|
||||
import { subscribe as menuSubscribe } from '$lib/menu';
|
||||
|
||||
export let data: LayoutData;
|
||||
|
||||
@ -40,7 +41,10 @@
|
||||
handleMenuActions(data.projectId);
|
||||
|
||||
onMount(() => {
|
||||
return unsubscribe(hotkeys.on('Meta+Shift+S', () => syncToCloud($project$?.id)));
|
||||
return unsubscribe(
|
||||
menuSubscribe(data.projectId),
|
||||
hotkeys.on('Meta+Shift+S', () => syncToCloud($project$?.id))
|
||||
);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user