Paginate beta history and refresh pages from events
This commit is contained in:
@@ -26,6 +26,11 @@ function updateDeployment(id: string, mutate: (d: PipelineDeployment) => void):
|
||||
export function startPipelineStream(): (() => void) | undefined {
|
||||
if (!browser || source) return;
|
||||
source = new EventSource('/api/events/pipeline');
|
||||
source.addEventListener('open', () => window.dispatchEvent(new Event('ec:pipeline-connected')));
|
||||
source.addEventListener('beta-changed', event => {
|
||||
try { window.dispatchEvent(new CustomEvent('ec:beta-changed', { detail: JSON.parse((event as MessageEvent).data) })); }
|
||||
catch { /* Reconnect refreshes authoritative state if an event is malformed. */ }
|
||||
});
|
||||
for (const event of ['server-changed', 'server-state', 'deployment-opened', 'fleet-invalidated']) {
|
||||
source.addEventListener(event, () => window.dispatchEvent(new Event('ec:fleet-changed')));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user