fix: derive green pallino from git status instead of in-memory tracker
The green dot (new note indicator) was disappearing after Cmd+S because markSaved cleared it from the in-memory newPaths set. Now resolveNoteStatus derives "new" status from git status (untracked/added files) so the green dot persists until the note is committed. The in-memory tracker is only used for the brief window between note creation and first save to disk. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -107,13 +107,10 @@ describe('useEditorSave', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it.each([
|
||||
{ name: 'onAfterSave', key: 'onAfterSave' as const },
|
||||
{ name: 'onNoteSaved', key: 'onNoteSaved' as const },
|
||||
])('calls $name callback after successful save', async ({ key }) => {
|
||||
it('calls onAfterSave callback after successful save', async () => {
|
||||
const cb = vi.fn()
|
||||
const { result } = renderHook(() =>
|
||||
useEditorSave({ updateVaultContent, setTabs, setToastMessage, [key]: cb })
|
||||
useEditorSave({ updateVaultContent, setTabs, setToastMessage, onAfterSave: cb })
|
||||
)
|
||||
|
||||
act(() => {
|
||||
@@ -142,15 +139,12 @@ describe('useEditorSave', () => {
|
||||
expect(onAfterSave).toHaveBeenCalledOnce()
|
||||
})
|
||||
|
||||
it.each([
|
||||
{ name: 'onAfterSave', key: 'onAfterSave' as const },
|
||||
{ name: 'onNoteSaved', key: 'onNoteSaved' as const },
|
||||
])('does not call $name when save fails', async ({ key }) => {
|
||||
it('does not call onAfterSave when save fails', async () => {
|
||||
mockInvokeFn.mockRejectedValueOnce(new Error('Disk full'))
|
||||
const consoleSpy = vi.spyOn(console, 'error').mockImplementation(() => {})
|
||||
const cb = vi.fn()
|
||||
const { result } = renderHook(() =>
|
||||
useEditorSave({ updateVaultContent, setTabs, setToastMessage, [key]: cb })
|
||||
useEditorSave({ updateVaultContent, setTabs, setToastMessage, onAfterSave: cb })
|
||||
)
|
||||
|
||||
act(() => {
|
||||
|
||||
Reference in New Issue
Block a user