fix(notes): persist new SHA and dedup files by path on edit
All checks were successful
CI / verify (push) Successful in 2m2s
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:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user