Interface dispatcher payload

& use constant in test
pull/21833/head
David Baker 2021-06-03 14:38:13 +01:00
parent 58652152c1
commit 8ef95a6237
4 changed files with 31 additions and 6 deletions

View File

@ -21,6 +21,7 @@ import Field from "../elements/Field";
import DialPad from './DialPad';
import dis from '../../../dispatcher/dispatcher';
import {replaceableComponent} from "../../../utils/replaceableComponent";
import { DialNumberPayload } from "../../../dispatcher/payloads/DialNumberPayload";
import { Action } from "../../../dispatcher/actions";
interface IProps {
@ -63,10 +64,11 @@ export default class DialpadModal extends React.PureComponent<IProps, IState> {
}
onDialPress = async () => {
dis.dispatch({
const payload: DialNumberPayload = {
action: Action.DialNumber,
number: this.state.value,
})
};
dis.dispatch(payload);
this.props.onFinished(true);
}

View File

@ -102,9 +102,7 @@ export enum Action {
/**
* Dial the phone number in the payload
* payload: {
* number: <phone number>,
* }
* payload: DialNumberPayload
*/
DialNumber = "dial_number",

View File

@ -0,0 +1,23 @@
/*
Copyright 2021 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import { ActionPayload } from "../payloads";
import { Action } from "../actions";
export interface DialNumberPayload extends ActionPayload {
action: Action.DialNumber;
number: string;
}

View File

@ -25,6 +25,8 @@ import DMRoomMap from '../src/utils/DMRoomMap';
import EventEmitter from 'events';
import SdkConfig from '../src/SdkConfig';
import { ActionPayload } from '../src/dispatcher/payloads';
import { Actions } from '../src/notifications/types';
import { Action } from '../src/dispatcher/actions';
const REAL_ROOM_ID = '$room1:example.org';
const MAPPED_ROOM_ID = '$room2:example.org';
@ -172,7 +174,7 @@ describe('CallHandler', () => {
}]);
dis.dispatch({
action: 'dial_number',
action: Action.DialNumber,
number: '01818118181',
}, true);