Paginate beta history and refresh pages from events
This commit is contained in:
@@ -46,6 +46,7 @@ export type BetaStage =
|
||||
export type BetaState = 'running' | 'ready-promote' | 'promoted' | 'rolled-back';
|
||||
|
||||
export type PipelineEvent =
|
||||
| { type: 'beta-changed'; betaId: number }
|
||||
| { type: 'fleet-invalidated' }
|
||||
| { type: 'server-telemetry'; entries: GameTelemetry[] }
|
||||
| { type: 'deployment-opened'; deploymentId: string; action: string; servers: string[] }
|
||||
@@ -79,6 +80,15 @@ class Bus extends EventEmitter {
|
||||
}
|
||||
|
||||
const bus = new Bus();
|
||||
const changedBetas = new Set<number>();
|
||||
export function invalidateBeta(betaId: number): void {
|
||||
const scheduled = changedBetas.size > 0;
|
||||
changedBetas.add(betaId);
|
||||
if (!scheduled) queueMicrotask(() => {
|
||||
const ids = [...changedBetas]; changedBetas.clear();
|
||||
for (const betaId of ids) bus.emit('event', { type: 'beta-changed', betaId });
|
||||
});
|
||||
}
|
||||
let invalidationPending = false;
|
||||
export function invalidateFleet(): void {
|
||||
if (invalidationPending) return;
|
||||
@@ -90,6 +100,7 @@ export function invalidateFleet(): void {
|
||||
export function emit(event: PipelineEvent): void {
|
||||
bus.emit('event', event);
|
||||
if (event.type === 'beta-opened' || event.type === 'beta-state' || event.type === 'beta-server-stage') invalidateFleet();
|
||||
if ('betaId' in event && event.type !== 'beta-changed') invalidateBeta(event.betaId);
|
||||
}
|
||||
|
||||
export function subscribe(listener: (event: PipelineEvent) => void): () => void {
|
||||
|
||||
Reference in New Issue
Block a user