mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-11-26 23:33:23 +00:00
fix(app): re-read the project filter when it changes outside the window
The main process re-reads app-filter.json whenever the file changes, which is what makes a hand edit land. The renderer only re-read it on its own config mutations, so a filter that appeared any other way left `projectFiltered` false: Settings kept offering Combined, the hero kept saying "Combined · …", and buildOverviewArgs had already dropped `--scope combined` because the filter was non-empty. The reading on screen was a local, project-filtered total labelled as the combined one. Re-read on a manual refresh and on every overview poll as well. It costs one statSync the main process already memoizes by stat stamp.
This commit is contained in:
parent
caae3df5cf
commit
6d45db1e08
2 changed files with 22 additions and 2 deletions
|
|
@ -493,6 +493,21 @@ describe('App shortcuts', () => {
|
|||
await waitFor(() => expect(localStorage.getItem('codeburn.scope')).toBe('local'))
|
||||
})
|
||||
|
||||
// app-filter.json is read by the main process on every fetch, so a hand edit
|
||||
// lands there at once. A renderer that only re-read on its own saves kept
|
||||
// Combined on screen over argv that had already dropped `--scope combined`.
|
||||
it('collapses combined scope when the filter appears outside the app', async () => {
|
||||
localStorage.setItem('codeburn.scope', 'combined')
|
||||
localStorage.setItem('codeburn.projectFiltered', '0')
|
||||
mocks.getProjectFilter.mockResolvedValueOnce({ project: [], exclude: [] })
|
||||
mocks.getProjectFilter.mockResolvedValue({ project: [], exclude: ['my-company'] })
|
||||
mocks.getOverview.mockResolvedValue(overviewPayload())
|
||||
render(<App />)
|
||||
await waitFor(() => expect(mocks.getOverview).toHaveBeenCalledWith('30days', 'all', undefined, undefined, undefined, 'combined'))
|
||||
await waitFor(() => expect(localStorage.getItem('codeburn.scope')).toBe('local'))
|
||||
await waitFor(() => expect(localStorage.getItem('codeburn.projectFiltered')).toBe('1'))
|
||||
})
|
||||
|
||||
it('records the filter for the next boot when the pane is empty', async () => {
|
||||
render(<App />)
|
||||
await waitFor(() => expect(localStorage.getItem('codeburn.projectFiltered')).toBe('0'))
|
||||
|
|
|
|||
|
|
@ -686,7 +686,12 @@ function AppMain() {
|
|||
setProvider(value)
|
||||
}
|
||||
|
||||
// Re-read on config invalidation: another window can save the pane too.
|
||||
// Re-read on config invalidation (another window can save the pane too), on a
|
||||
// manual refresh, and on every overview poll. The main process honours a hand
|
||||
// edit of app-filter.json the moment the file changes, so a renderer that only
|
||||
// re-read on its own saves kept offering Combined while buildOverviewArgs had
|
||||
// already dropped `--scope combined` — a local, filtered total under a
|
||||
// "Combined · …" headline, which is the one reading the pane must never give.
|
||||
useEffect(() => {
|
||||
let cancelled = false
|
||||
void Promise.resolve().then(() => codeburn.getProjectFilter())
|
||||
|
|
@ -698,7 +703,7 @@ function AppMain() {
|
|||
})
|
||||
.catch(() => { /* an older preload has no getProjectFilter to honour */ })
|
||||
return () => { cancelled = true }
|
||||
}, [snapshotRevision])
|
||||
}, [snapshotRevision, refreshToken, overview.data])
|
||||
|
||||
// Collapse the stored preference too, so clearing the filter later starts
|
||||
// from local instead of silently restoring a combined view.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue