fix: refresh watch scope on provider fallback
This commit is contained in:
parent
06036460e9
commit
9ed1988346
2 changed files with 13 additions and 1 deletions
|
|
@ -76,7 +76,7 @@ export function markTeamEngaged(teamName: string, nowMs: number = Date.now()): v
|
|||
return;
|
||||
}
|
||||
const currentScope = computeTeamWatchScope(nowMs);
|
||||
const wasInScope = currentScope === null || currentScope.has(teamName);
|
||||
const wasInScope = currentScope?.has(teamName) === true;
|
||||
engagedAtByTeam.set(teamName, nowMs);
|
||||
if (!wasInScope) {
|
||||
scopeChangeListener?.();
|
||||
|
|
|
|||
|
|
@ -69,6 +69,18 @@ describe('teamWatchScope', () => {
|
|||
expect(computeTeamWatchScope(0)).toBeNull();
|
||||
});
|
||||
|
||||
it('notifies on engagement when alive provider fails so watcher can refresh to fallback', () => {
|
||||
const listener = vi.fn();
|
||||
setAliveTeamsProvider(() => {
|
||||
throw new Error('boom');
|
||||
});
|
||||
setTeamWatchScopeChangeListener(listener);
|
||||
|
||||
markTeamEngaged('x', 0);
|
||||
|
||||
expect(listener).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('ignores empty team names', () => {
|
||||
const listener = vi.fn();
|
||||
setTeamWatchScopeChangeListener(listener);
|
||||
|
|
|
|||
Loading…
Reference in a new issue