2018-07-15 14:50:38 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import { BaseApp } from '../../../base/app';
|
|
|
|
|
|
|
|
import { incomingCallReceived } from '../actions';
|
|
|
|
import IncomingCallPage from './IncomingCallPage';
|
|
|
|
|
2018-07-16 16:36:32 +00:00
|
|
|
/**
|
|
|
|
* The type of the React {@code Component} props of {@link IncomingCallApp}.
|
|
|
|
*/
|
2018-07-15 14:50:38 +00:00
|
|
|
type Props = {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* URL of the avatar for the caller.
|
|
|
|
*/
|
2018-07-16 16:36:32 +00:00
|
|
|
callerAvatarURL: string,
|
2018-07-15 14:50:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Name of the caller.
|
|
|
|
*/
|
|
|
|
callerName: string,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether this is a video call or not.
|
|
|
|
*/
|
|
|
|
hasVideo: boolean
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Root application component for incoming call.
|
|
|
|
*
|
|
|
|
* @extends BaseApp
|
|
|
|
*/
|
|
|
|
export default class IncomingCallApp extends BaseApp<Props> {
|
|
|
|
_init: Promise<*>;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Navigates to {@link IncomingCallPage} upon mount.
|
|
|
|
*
|
2018-07-16 16:36:32 +00:00
|
|
|
* NOTE: This was implmented here instead of in a middleware for the
|
|
|
|
* {@link APP_WILL_MOUNT} action because that would run also for
|
|
|
|
* {@link App}.
|
2018-07-15 14:50:38 +00:00
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2019-01-01 23:50:11 +00:00
|
|
|
componentDidMount() {
|
|
|
|
super.componentDidMount();
|
2018-07-15 14:50:38 +00:00
|
|
|
|
|
|
|
this._init.then(() => {
|
|
|
|
const { dispatch } = this.state.store;
|
|
|
|
const {
|
2018-07-16 16:36:32 +00:00
|
|
|
callerAvatarURL: avatarUrl,
|
2018-07-15 14:50:38 +00:00
|
|
|
callerName: name,
|
|
|
|
hasVideo
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
dispatch(incomingCallReceived({
|
|
|
|
avatarUrl,
|
2018-07-16 16:36:32 +00:00
|
|
|
hasVideo,
|
|
|
|
name
|
2018-07-15 14:50:38 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
super._navigate({ component: IncomingCallPage });
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|