starfleet-ui
Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.
Dernier runRéussi#6 · main · 2 min 01 s
0Étoiles
0Forks
0Issues
| 1 | /** |
| 2 | * The entry to resume the captain's event stream after, sent upstream as `Last-Event-ID`. |
| 3 | * Without one the API replays the whole log from the first entry. |
| 4 | * |
| 5 | * `EventSource` cannot set headers, so the HUD passes the newest entry it already shows as |
| 6 | * `?after=`. When the browser reconnects by itself it sends its own `Last-Event-ID`, which is |
| 7 | * newer, so that one wins. |
| 8 | */ |
| 9 | export function resumeId(lastEventId: string | null, after: string | null): string | null { |
| 10 | for (const v of [lastEventId, after]) { |
| 11 | const s = v?.trim(); |
| 12 | if (s && /^\d+$/.test(s)) return s; |
| 13 | } |
| 14 | return null; |
| 15 | } |