@@ -947,6 +947,7 @@ export class CallViewModel extends ViewModel {
947947 * The current call pickup state of the call.
948948 * - "unknown": The client has not yet sent the notification event. We don't know if it will because it first needs to send its own membership.
949949 * Then we can conclude if we were the first one to join or not.
950+ * This may also be set if we are disconnected.
950951 * - "ringing": The call is ringing on other devices in this room (This client should give audiovisual feedback that this is happening).
951952 * - "timeout": No-one picked up in the defined time this call should be ringing on others devices.
952953 * The call failed. If desired this can be used as a trigger to exit the call.
@@ -959,13 +960,20 @@ export class CallViewModel extends ViewModel {
959960 ? this . scope . behavior <
960961 "unknown" | "ringing" | "timeout" | "decline" | "success"
961962 > (
962- this . someoneElseJoined$ . pipe (
963- switchMap ( ( someoneElseJoined ) =>
964- someoneElseJoined
965- ? of ( "success" as const )
966- : // Show the ringing state of the most recent ringing attempt.
967- this . ring$ . pipe ( switchAll ( ) ) ,
968- ) ,
963+ combineLatest ( [
964+ this . livekitConnectionState$ ,
965+ this . someoneElseJoined$ ,
966+ ] ) . pipe (
967+ switchMap ( ( [ livekitConnectionState , someoneElseJoined ] ) => {
968+ if ( livekitConnectionState === ConnectionState . Disconnected ) {
969+ // Do not ring until we're connected.
970+ return of ( "unknown" as const ) ;
971+ } else if ( someoneElseJoined ) {
972+ return of ( "success" as const ) ;
973+ }
974+ // Show the ringing state of the most recent ringing attempt.
975+ return this . ring$ . pipe ( switchAll ( ) ) ;
976+ } ) ,
969977 // The state starts as 'unknown' because we don't know if the RTC
970978 // session will actually send a notify event yet. It will only be
971979 // known once we send our own membership and see that we were the
@@ -1682,7 +1690,7 @@ export class CallViewModel extends ViewModel {
16821690 private readonly livekitRoom : LivekitRoom ,
16831691 private readonly mediaDevices : MediaDevices ,
16841692 private readonly options : CallViewModelOptions ,
1685- private readonly livekitConnectionState$ : Observable < ECConnectionState > ,
1693+ public readonly livekitConnectionState$ : Observable < ECConnectionState > ,
16861694 private readonly handsRaisedSubject$ : Observable <
16871695 Record < string , RaisedHandInfo >
16881696 > ,
0 commit comments