fix(notes): persist new SHA and dedup files by path on edit
All checks were successful
CI / verify (push) Successful in 2m2s

Editing a note in a stacked note saved cache without the path, so
store.files never received the new SHA and lookups went stale. Pass the
path through, and make addFile dedup by path as well as SHA so an edit
(same path, new SHA) replaces the old entry instead of duplicating it.
This commit is contained in:
Julien Calixte
2026-06-28 23:52:37 +02:00
parent a7d846aa33
commit 1b47101340
3 changed files with 17 additions and 2 deletions

View File

@@ -105,6 +105,18 @@ describe("userRepo store — synchronous mutations", () => {
expect(vi.mocked(data.update)).not.toHaveBeenCalled()
})
it("addFile replaces the entry at the same path when content (sha) changed", () => {
const store = useUserRepoStore()
store.user = "alice"
store.repo = "notes"
store.files = [{ sha: "old", path: "a.md", type: "blob" }] as never
store.addFile({ sha: "new", path: "a.md", type: "blob" } as never)
expect(store.files).toEqual([{ sha: "new", path: "a.md", type: "blob" }])
expect(vi.mocked(data.update)).toHaveBeenCalled()
})
it("setFontFamily initializes userSettings when absent and persists to localStorage", () => {
const store = useUserRepoStore()
store.user = "alice"