| 631 | * (somewhat cheekily named) |
| 632 | */ |
| 633 | export class ElementCall extends Call { |
| 634 | public readonly STUCK_DEVICE_TIMEOUT_MS = 1000 * 60 * 60; // 1 hour |
| 635 | |
| 636 | private settingsStoreCallEncryptionWatcher?: string; |
| 637 | private terminationTimer?: number; |
| 638 | |
| 639 | public get presented(): boolean { |
| 640 | return super.presented; |
| 641 | } |
| 642 | public set presented(value: boolean) { |
| 643 | super.presented = value; |
| 644 | this.checkDestroy(); |
| 645 | } |
| 646 | |
| 647 | public widgetGenerationParameters: WidgetGenerationParameters = {}; |
| 648 | |
| 649 | /** |
| 650 | * Calculate the correct intent (and associated parameters) for an Element Call room. Paarameters |
| 651 | * will be applied to the `params` instance. |
| 652 | * |
| 653 | * @param params Existing URL parameters |
| 654 | * @param client The current client. |
| 655 | * @param roomId The room ID for the call. |
| 656 | */ |
| 657 | private static appendRoomParams( |
| 658 | params: URLSearchParams, |
| 659 | client: MatrixClient, |
| 660 | roomId: string, |
| 661 | { voiceOnly }: WidgetGenerationParameters, |
| 662 | ): void { |
| 663 | const room = client.getRoom(roomId); |
| 664 | if (!room) { |
| 665 | // If the room isn't known then skip setting an intent. |
| 666 | return; |
| 667 | } else if (isVideoRoom(room)) { |
| 668 | // Video rooms already exist, so just treat as if we're joining a group call. |
| 669 | params.append("intent", ElementCallIntent.JoinExisting); |
| 670 | // Video rooms should always return to lobby. |
| 671 | params.append("returnToLobby", "true"); |
| 672 | // Never skip the lobby, we always want to give the caller a chance to explicitly join. |
| 673 | params.append("skipLobby", "false"); |
| 674 | return; |
| 675 | } |
| 676 | |
| 677 | const isDM = !!DMRoomMap.shared().getUserIdForRoomId(room.roomId); |
| 678 | const oldestCallMember = client.matrixRTC.getRoomSession(room).getOldestMembership(); |
| 679 | const hasCallStarted = !!oldestCallMember && oldestCallMember.sender !== client.getSafeUserId(); |
| 680 | if (isDM) { |
| 681 | if (hasCallStarted) { |
| 682 | params.append( |
| 683 | "intent", |
| 684 | voiceOnly ? ElementCallIntent.JoinExistingDMVoice : ElementCallIntent.JoinExistingDM, |
| 685 | ); |
| 686 | } else { |
| 687 | params.append("intent", voiceOnly ? ElementCallIntent.StartCallDMVoice : ElementCallIntent.StartCallDM); |
| 688 | } |
| 689 | } else { |
| 690 | if (hasCallStarted) { |
nothing calls this directly
no test coverage detected