From 1a9b532edf20c25286e6b2451fd4e7740dc7285e Mon Sep 17 00:00:00 2001 From: Kiril Videlov Date: Sun, 11 Feb 2024 13:02:01 +0100 Subject: [PATCH] persist lane collapsed state in local storage --- .../lib/components/ActiveBranchStatus.svelte | 23 +++++++++---------- .../src/lib/components/BranchCard.svelte | 10 ++++---- .../src/lib/components/BranchHeader.svelte | 10 ++++---- .../BranchHeaderSecondaryActions.svelte | 9 ++++---- .../src/lib/components/BranchLane.svelte | 4 +--- gitbutler-ui/src/lib/config/config.ts | 5 ++++ 6 files changed, 32 insertions(+), 29 deletions(-) diff --git a/gitbutler-ui/src/lib/components/ActiveBranchStatus.svelte b/gitbutler-ui/src/lib/components/ActiveBranchStatus.svelte index 1bfe29e28..34271a994 100644 --- a/gitbutler-ui/src/lib/components/ActiveBranchStatus.svelte +++ b/gitbutler-ui/src/lib/components/ActiveBranchStatus.svelte @@ -2,6 +2,7 @@ import Tag from '$lib/components/Tag.svelte'; import { normalizeBranchName } from '$lib/utils/branch'; import { open } from '@tauri-apps/api/shell'; + import type { Persisted } from '$lib/persisted/persisted'; import type { BaseBranch, Branch } from '$lib/vbranches/types'; export let base: BaseBranch | undefined | null; @@ -9,7 +10,7 @@ export let prUrl: string | undefined; export let isUnapplied = false; export let hasIntegratedCommits = false; - export let isLaneCollapsed = false; + export let isLaneCollapsed: Persisted; {#if !branch.upstream} @@ -19,7 +20,7 @@ color="light" help="These changes are stashed away from your working directory." reversedDirection - verticalOrientation={isLaneCollapsed}>unappliedunapplied {:else if hasIntegratedCommits} IntegratedIntegrated {:else} VirtualVirtual {/if} {#if !isUnapplied} - origin/{branch.upstreamName - ? branch.upstreamName - : normalizeBranchName(branch.name)} {/if} {:else} @@ -54,7 +53,7 @@ color="dark" icon="remote-branch-small" help="At least some of your changes have been pushed" - verticalOrientation={isLaneCollapsed} + verticalOrientation={$isLaneCollapsed} reversedDirection>Remote { const url = base?.branchUrl(branch.upstream?.name); if (url) open(url); @@ -71,7 +70,7 @@ e.stopPropagation(); }} > - {isLaneCollapsed ? 'View branch' : `origin/${branch.upstream?.name}`} + {$isLaneCollapsed ? 'View branch' : `origin/${branch.upstream?.name}`} {#if prUrl} { const url = prUrl; if (url) open(url); diff --git a/gitbutler-ui/src/lib/components/BranchCard.svelte b/gitbutler-ui/src/lib/components/BranchCard.svelte index 4c7c13a2f..635488900 100644 --- a/gitbutler-ui/src/lib/components/BranchCard.svelte +++ b/gitbutler-ui/src/lib/components/BranchCard.svelte @@ -7,6 +7,7 @@ import ImgThemed from '$lib/components/ImgThemed.svelte'; import Resizer from '$lib/components/Resizer.svelte'; import { projectAiGenEnabled } from '$lib/config/config'; + import { projectLaneCollapsed } from '$lib/config/config'; import { isDraggableFile, isDraggableHunk, @@ -49,10 +50,7 @@ let rsViewport: HTMLElement; const userSettings = getContext(SETTINGS_CONTEXT); - const defaultBranchWidthRem = persisted( - 24, - 'defaulBranchWidth' + project.id - ); + const defaultBranchWidthRem = persisted(24, 'defaulBranchWidth' + project.id); const laneWidthKey = 'laneWidth_'; let laneWidth: number; @@ -130,10 +128,10 @@ } } - let isLaneCollapsed: boolean; + $: isLaneCollapsed = projectLaneCollapsed(project.id, branch.id); -{#if isLaneCollapsed} +{#if $isLaneCollapsed}
; export let githubService: GitHubService; $: pr$ = githubService.get(branch.upstreamName); @@ -122,7 +123,7 @@ $: hasIntegratedCommits = branch.commits?.some((b) => b.isIntegrated); -{#if isLaneCollapsed} +{#if $isLaneCollapsed}
@@ -134,7 +135,7 @@ color="neutral" help="Collapse lane" on:click={() => { - isLaneCollapsed = false; + $isLaneCollapsed = false; }} />
@@ -175,6 +176,7 @@ {branch} {isUnapplied} {hasIntegratedCommits} + {isLaneCollapsed} prUrl={$pr$?.htmlUrl} />