Put call on hold when transfer dialog is opened (#7669)

And take it off hold if the dialog is cancelled.

Also changes the onFinished signature of invitedialog which claimed
to return an array of strings but never did, so now it just returns
a boolean.
This commit is contained in:
David Baker 2022-01-28 17:05:57 +00:00 committed by GitHub
parent b04d2de313
commit 7c20eb9b74
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 15 deletions

View file

@ -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";
@ -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`);

View file

@ -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 {
@ -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();
};

View file

@ -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.
@ -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;
}
@ -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({
@ -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);
@ -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) => {
@ -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) => {
@ -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());
};