Drop unused card expansions code

This commit is contained in:
Mattias Granlund 2024-01-28 22:20:05 +01:00
parent 76e6d3bf7e
commit 45c84564d4
2 changed files with 1 additions and 46 deletions

View File

@ -10,13 +10,12 @@
type DraggableHunk
} from '$lib/draggables';
import { filesToOwnership, type Ownership } from '$lib/vbranches/ownership';
import { getExpandedWithCacheFallback } from './cache';
import type { BranchController } from '$lib/vbranches/branchController';
import type { User, getCloudApiClient } from '$lib/backend/cloud';
import Resizer from '$lib/components/Resizer.svelte';
import lscache from 'lscache';
import CommitDialog from './CommitDialog.svelte';
import { get, writable, type Writable } from 'svelte/store';
import { get, type Writable } from 'svelte/store';
import { computedAddedRemoved } from '$lib/vbranches/fileStatus';
import type { GitHubService } from '$lib/github/service';
import { isDraggableRemoteCommit, type DraggableRemoteCommit } from '$lib/draggables';
@ -45,8 +44,6 @@
export let selectedOwnership: Writable<Ownership>;
export let commitBoxOpen: Writable<boolean>;
const allExpanded = writable(false);
const allCollapsed = writable(false);
const aiGenEnabled = projectAiGenEnabled(project.id);
let rsViewport: HTMLElement;
@ -57,17 +54,6 @@
let laneWidth: number;
$: {
// On refresh we need to check expansion status from localStorage
branch.files && expandFromCache();
}
function expandFromCache() {
// Exercise cache lookup for all files.
$allExpanded = branch.files.every((f) => getExpandedWithCacheFallback(f));
$allCollapsed = branch.files.every((f) => getExpandedWithCacheFallback(f) == false);
}
$: if ($commitBoxOpen && branch.files.length === 0) {
$commitBoxOpen = false;
}
@ -100,7 +86,6 @@
}
onMount(() => {
expandFromCache();
laneWidth = lscache.get(laneWidthKey + branch.id);
});

View File

@ -1,30 +0,0 @@
import type { File } from '$lib/vbranches/types';
const TRUE_KEY = '1';
const FALSE_KEY = '0';
function getKey(path: string): string {
return `expanded:${path}`;
}
export function getExpandedWithCacheFallback(file: File) {
if (file.expanded != undefined) {
return file.expanded; // No need to check after initial load
}
const value = localStorage.getItem(`expanded:${file.path}`);
if (value == TRUE_KEY) {
file.expanded = true;
} else if (value == FALSE_KEY) {
file.expanded = false;
}
return file.expanded;
}
export function setExpandedWithCache(file: File, value: boolean | undefined): void {
file.expanded = value;
if (file.expanded != undefined) {
localStorage.setItem(getKey(file.path), value ? TRUE_KEY : FALSE_KEY);
} else {
localStorage.removeItem(getKey(file.path));
}
}