-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcache.ts
More file actions
19 lines (18 loc) · 787 Bytes
/
Copy pathcache.ts
File metadata and controls
19 lines (18 loc) · 787 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import { getEventsForOffer } from '@/server/events/log';
import type { ActivityEvent } from '@/server/events/types';
// Cache is valid only while the offer's tail is an investigation_completed
// event — any material state change (offer_updated, activity_status_changed,
// milestone_completed, etc.) lands after the investigation and invalidates it,
// which is what prompts the "Re-investigate" affordance.
export function findCachedInvestigation(
offerId: string,
_atSeq: number,
): Extract<ActivityEvent, { kind: 'investigation_completed' }> | null {
const events = getEventsForOffer(offerId);
for (let i = events.length - 1; i >= 0; i--) {
const event = events[i];
if (event.kind === 'investigation_completed') return event;
return null;
}
return null;
}