feat(notes): keep old shas as immutable snapshots
All checks were successful
CI / verify (push) Successful in 1m5s

Cache content under its own sha (write-once) with the path key as the
latest pointer, and advance the stack handle to the new sha after an
edit or pull. A shared link keeps showing exactly what was shared, while
the live view follows your changes.
This commit is contained in:
Julien Calixte
2026-06-29 00:43:56 +02:00
parent 08d2d804ff
commit 2f8d3c24a4
4 changed files with 99 additions and 2 deletions

View File

@@ -149,9 +149,25 @@ export const useRouteQueryStackedNotes = () => {
scrollToFocusedNote({ noteId: selector ?? sha, hash, anchorTop })
}
// Advance a note's handle in place when its content changes (edit / pull):
// the live view follows to the new sha, while any previously-shared link
// keeps pointing at the old, now-immutable snapshot.
const replaceStackedNote = (oldSha: string, newSha: string) => {
if (!oldSha || !newSha || oldSha === newSha) {
return
}
if (!stackedNotes.value.includes(oldSha)) {
return
}
stackedNotes.value = stackedNotes.value.map((note) =>
note === oldSha ? newSha : note
)
}
return {
stackedNotes: readonly(stackedNotes),
addStackedNote,
replaceStackedNote,
scrollToFocusedNote
}
}