mirror of
https://seed.radicle.dev/rad:z4D5UCArafTzTQpDZNQRuqswh3ury.git
synced 2026-11-11 14:20:38 +08:00
Integrate pierre's diffs into commit view
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import type { FileDiffMetadata } from "@pierre/diffs";
|
||||
|
||||
export type FileStatus = "added" | "deleted" | "modified" | "moved" | "copied";
|
||||
export type FileNote = "binary" | "empty";
|
||||
|
||||
// Reactive state for a single `DiffFileHeader`. One instance is created per
|
||||
// pooled CodeView item element and mutated in place as the element is recycled
|
||||
// for different files while scrolling (see `PierreDiff.svelte`), so the header
|
||||
// updates without remounting.
|
||||
export class DiffFileHeaderState {
|
||||
fileDiff = $state.raw<FileDiffMetadata | undefined>(undefined);
|
||||
status = $state<FileStatus | undefined>(undefined);
|
||||
note = $state<FileNote | undefined>(undefined);
|
||||
collapsed = $state(false);
|
||||
// `undefined` hides the actions menu.
|
||||
text = $state<(() => Promise<string>) | undefined>(undefined);
|
||||
// Not `$state`: read only at click time. Set per file in `syncHeaderSlots`.
|
||||
onToggleCollapse: () => void = () => {
|
||||
// Replaced per file.
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user