Model ConnectionState as a discriminated union

The enum mixed our own lifecycle states with a copy of livekit-client's
connection states, and errors were smuggled through the same observable as
a separate union member. A discriminated union keeps the LiveKit state
nested under "authenticated", carries the error as data, and lets the
local member represent the time before a connection exists as an
"initializing" state instead of null.
This commit is contained in:
Robin authored and Johannes Marbach committed 2026-10-12 10:08:22 +02:00
1 parent 3f030e64dd
commit 4e4ab23cda
5 files changed
+134 -97

No files matched your search

+2 -2
View File
@@ -1662,9 +1662,9 @@ export function createCallViewModel$(
returnObject.publishError = value.media;
else if (
typeof value.media === "object" &&
value.media.connection instanceof ElementCallError
value.media.connection.state === "error"
)
returnObject.connectionError = value.media.connection;
returnObject.connectionError = value.media.connection.error;
return returnObject;
}),
),