mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-22 17:11:43 +03:00
Use Svelte Context API for passing user settings
This commit is contained in:
parent
fce7ffde19
commit
de7973ccb8
@ -1,6 +1,7 @@
|
||||
import { get, writable, type Writable } from '@square/svelte-store';
|
||||
|
||||
const SETTINGS_KEY = 'settings-json';
|
||||
export const SETTINGS_CONTEXT = Symbol();
|
||||
|
||||
export interface Settings {
|
||||
aiSummariesEnabled?: boolean;
|
||||
|
@ -3,7 +3,8 @@
|
||||
import NewBranchDropZone from './NewBranchDropZone.svelte';
|
||||
import type { Branch } from '$lib/api/ipc/vbranches';
|
||||
import type { VirtualBranchOperations } from './vbranches';
|
||||
import type { SettingsStore } from '$lib/userSettings';
|
||||
import { SETTINGS_CONTEXT, type SettingsStore } from '$lib/userSettings';
|
||||
import { setContext } from 'svelte';
|
||||
|
||||
export let projectId: string;
|
||||
export let projectPath: string;
|
||||
@ -11,6 +12,8 @@
|
||||
export let virtualBranches: VirtualBranchOperations;
|
||||
export let userSettings: SettingsStore;
|
||||
|
||||
setContext(SETTINGS_CONTEXT, userSettings);
|
||||
|
||||
let dragged: any;
|
||||
let dropZone: HTMLDivElement;
|
||||
let priorPosition = 0;
|
||||
@ -97,7 +100,6 @@
|
||||
branchId={id}
|
||||
{virtualBranches}
|
||||
{projectPath}
|
||||
{userSettings}
|
||||
/>
|
||||
{/each}
|
||||
<NewBranchDropZone {virtualBranches} />
|
||||
|
@ -15,7 +15,6 @@
|
||||
import type { VirtualBranchOperations } from './vbranches';
|
||||
import PopupMenu from '../../../lib/components/PopupMenu/PopupMenu.svelte';
|
||||
import PopupMenuItem from '../../../lib/components/PopupMenu/PopupMenuItem.svelte';
|
||||
import type { SettingsStore } from '$lib/userSettings';
|
||||
|
||||
const dispatch = createEventDispatcher<{
|
||||
empty: never;
|
||||
@ -31,7 +30,6 @@
|
||||
export let projectId: string;
|
||||
export let order: number;
|
||||
export let virtualBranches: VirtualBranchOperations;
|
||||
export let userSettings: SettingsStore;
|
||||
|
||||
$: remoteCommits = commits.filter((c) => c.isRemote);
|
||||
$: localCommits = commits.filter((c) => !c.isRemote);
|
||||
@ -253,7 +251,6 @@
|
||||
filepath={file.path}
|
||||
expanded={file.expanded}
|
||||
hunks={file.hunks}
|
||||
{userSettings}
|
||||
{maximized}
|
||||
on:update={(e) => {
|
||||
handleFileUpdate(file.id, e.detail);
|
||||
|
@ -8,14 +8,16 @@
|
||||
import { open } from '@tauri-apps/api/shell';
|
||||
import PopupMenu from '$lib/components/PopupMenu/PopupMenu.svelte';
|
||||
import PopupMenuItem from '$lib/components/PopupMenu/PopupMenuItem.svelte';
|
||||
import type { SettingsStore } from '$lib/userSettings';
|
||||
import { SETTINGS_CONTEXT, type SettingsStore } from '$lib/userSettings';
|
||||
import { getContext } from 'svelte';
|
||||
|
||||
const userSettings = getContext<SettingsStore>(SETTINGS_CONTEXT);
|
||||
|
||||
export let id: string;
|
||||
export let projectPath: string;
|
||||
export let filepath: string;
|
||||
export let hunks: Hunk[];
|
||||
export let maximized: boolean;
|
||||
export let userSettings: SettingsStore;
|
||||
|
||||
const dispatch = createEventDispatcher<{
|
||||
expanded: boolean;
|
||||
|
Loading…
Reference in New Issue
Block a user