feat(notes): keep old shas as immutable snapshots
All checks were successful
CI / verify (push) Successful in 1m5s
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:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user