Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Put call on hold when transfer dialog is opened #7669

Merged
merged 1 commit into from
Jan 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/CallHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import { WidgetType } from "./widgets/WidgetType";
import { SettingLevel } from "./settings/SettingLevel";
import QuestionDialog from "./components/views/dialogs/QuestionDialog";
import ErrorDialog from "./components/views/dialogs/ErrorDialog";
import InviteDialog, { KIND_CALL_TRANSFER } from "./components/views/dialogs/InviteDialog";
import WidgetStore from "./stores/WidgetStore";
import { WidgetMessagingStore } from "./stores/widgets/WidgetMessagingStore";
import { ElementWidgetActions } from "./stores/widgets/ElementWidgetActions";
Expand Down Expand Up @@ -1100,6 +1101,23 @@ export default class CallHandler extends EventEmitter {
});
}

/*
* Shows the transfer dialog for a call, signalling to the other end that
* a transfer is about to happen
*/
public showTransferDialog(call: MatrixCall): void {
call.setRemoteOnHold(true);
const { finished } = Modal.createTrackedDialog(
'Transfer Call', '', InviteDialog, { kind: KIND_CALL_TRANSFER, call },
/*className=*/"mx_InviteDialog_transferWrapper", /*isPriority=*/false, /*isStatic=*/true,
);
finished.then((results: boolean[]) => {
if (results.length === 0 || results[0] === false) {
call.setRemoteOnHold(false);
}
});
}

private addCallForRoom(roomId: string, call: MatrixCall, changedRooms = false): void {
if (this.calls.has(roomId)) {
logger.log(`Couldn't add call to room ${roomId}: already have a call for this room`);
Expand Down
7 changes: 1 addition & 6 deletions src/components/views/context_menus/CallContextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ import { MatrixCall } from 'matrix-js-sdk/src/webrtc/call';
import { _t } from '../../../languageHandler';
import ContextMenu, { IProps as IContextMenuProps, MenuItem } from '../../structures/ContextMenu';
import CallHandler from '../../../CallHandler';
import InviteDialog, { KIND_CALL_TRANSFER } from '../dialogs/InviteDialog';
import Modal from '../../../Modal';
import { replaceableComponent } from "../../../utils/replaceableComponent";

interface IProps extends IContextMenuProps {
Expand Down Expand Up @@ -52,10 +50,7 @@ export default class CallContextMenu extends React.Component<IProps> {
};

onTransferClick = () => {
Modal.createTrackedDialog(
'Transfer Call', '', InviteDialog, { kind: KIND_CALL_TRANSFER, call: this.props.call },
/*className=*/"mx_InviteDialog_transferWrapper", /*isPriority=*/false, /*isStatic=*/true,
);
CallHandler.instance.showTransferDialog(this.props.call);
this.props.onFinished();
};

Expand Down
20 changes: 11 additions & 9 deletions src/components/views/dialogs/InviteDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,10 @@ class DMRoomTile extends React.PureComponent<IDMRoomTileProps> {
}

interface IInviteDialogProps {
// Takes an array of user IDs/emails to invite.
onFinished: (toInvite?: string[]) => void;
// Takes a boolean which is true if a user / users were invited /
// a call transfer was initiated or false if the dialog was cancelled
// with no action taken.
onFinished: (success: boolean) => void;

// The kind of invite being performed. Assumed to be KIND_DM if
// not provided.
Expand Down Expand Up @@ -685,7 +687,7 @@ export default class InviteDialog extends React.PureComponent<IInviteDialogProps
should_peek: false,
joining: false,
});
this.props.onFinished();
this.props.onFinished(true);
return;
}

Expand Down Expand Up @@ -732,7 +734,7 @@ export default class InviteDialog extends React.PureComponent<IInviteDialogProps
}

await createRoom(createRoomOptions);
this.props.onFinished();
this.props.onFinished(true);
} catch (err) {
logger.error(err);
this.setState({
Expand Down Expand Up @@ -764,7 +766,7 @@ export default class InviteDialog extends React.PureComponent<IInviteDialogProps
const result = await inviteMultipleToRoom(this.props.roomId, targetIds, true);
CountlyAnalytics.instance.trackSendInvite(startTime, this.props.roomId, targetIds.length);
if (!this.shouldAbortAfterInviteError(result, room)) { // handles setting error message too
this.props.onFinished();
this.props.onFinished(true);
}
} catch (err) {
logger.error(err);
Expand Down Expand Up @@ -801,7 +803,7 @@ export default class InviteDialog extends React.PureComponent<IInviteDialogProps
this.state.consultFirst,
);
}
this.props.onFinished();
this.props.onFinished(true);
};

private onKeyDown = (e) => {
Expand All @@ -824,7 +826,7 @@ export default class InviteDialog extends React.PureComponent<IInviteDialogProps
};

private onCancel = () => {
this.props.onFinished([]);
this.props.onFinished(false);
};

private updateSuggestions = async (term) => {
Expand Down Expand Up @@ -1086,11 +1088,11 @@ export default class InviteDialog extends React.PureComponent<IInviteDialogProps
private onManageSettingsClick = (e) => {
e.preventDefault();
dis.fire(Action.ViewUserSettings);
this.props.onFinished();
this.props.onFinished(false);
};

private onCommunityInviteClick = (e) => {
this.props.onFinished();
this.props.onFinished(false);
showCommunityInviteDialog(CommunityPrototypeStore.instance.getSelectedCommunityId());
};

Expand Down