2023-02-14 09:50:46 +00:00
|
|
|
import React from 'react';
|
2016-10-05 14:36:59 +00:00
|
|
|
|
2018-07-11 09:42:43 +00:00
|
|
|
import { BaseApp } from '../../base/app';
|
2017-07-26 19:27:29 +00:00
|
|
|
import { toURLString } from '../../base/util';
|
2018-07-11 09:42:43 +00:00
|
|
|
import { appNavigate } from '../actions';
|
2018-07-11 08:57:07 +00:00
|
|
|
import { getDefaultURL } from '../functions';
|
2017-06-09 10:26:21 +00:00
|
|
|
|
2016-10-05 14:36:59 +00:00
|
|
|
/**
|
2018-07-12 16:16:57 +00:00
|
|
|
* The type of React {@code Component} props of {@link AbstractApp}.
|
2016-10-05 14:36:59 +00:00
|
|
|
*/
|
2018-07-11 09:42:43 +00:00
|
|
|
export type Props = {
|
|
|
|
|
2017-01-16 00:28:02 +00:00
|
|
|
/**
|
2018-07-11 09:42:43 +00:00
|
|
|
* XXX Refer to the implementation of loadURLObject: in
|
|
|
|
* ios/sdk/src/JitsiMeetView.m for further information.
|
2017-01-16 00:28:02 +00:00
|
|
|
*/
|
2018-07-11 09:42:43 +00:00
|
|
|
timestamp: any,
|
2017-12-14 17:02:32 +00:00
|
|
|
|
2018-07-11 09:42:43 +00:00
|
|
|
/**
|
|
|
|
* The URL, if any, with which the app was launched.
|
|
|
|
*/
|
|
|
|
url: Object | string
|
|
|
|
};
|
2017-12-14 17:02:32 +00:00
|
|
|
|
2018-07-11 09:42:43 +00:00
|
|
|
/**
|
|
|
|
* Base (abstract) class for main App component.
|
|
|
|
*
|
|
|
|
* @abstract
|
|
|
|
*/
|
|
|
|
export class AbstractApp extends BaseApp<Props, *> {
|
2022-01-11 15:03:42 +00:00
|
|
|
/**
|
|
|
|
* The deferred for the initialisation {{promise, resolve, reject}}.
|
|
|
|
*/
|
|
|
|
_init: Object;
|
2017-01-16 00:28:02 +00:00
|
|
|
|
2016-10-05 14:36:59 +00:00
|
|
|
/**
|
2018-07-10 09:11:45 +00:00
|
|
|
* Initializes the app.
|
2016-10-05 14:36:59 +00:00
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
2022-01-07 13:18:24 +00:00
|
|
|
async componentDidMount() {
|
|
|
|
await super.componentDidMount();
|
2017-12-14 17:02:32 +00:00
|
|
|
|
2022-01-07 13:18:24 +00:00
|
|
|
// If a URL was explicitly specified to this React Component, then
|
|
|
|
// open it; otherwise, use a default.
|
|
|
|
this._openURL(toURLString(this.props.url) || this._getDefaultURL());
|
2016-10-05 14:36:59 +00:00
|
|
|
}
|
|
|
|
|
2017-01-26 21:29:28 +00:00
|
|
|
/**
|
2019-01-04 03:34:46 +00:00
|
|
|
* Implements React Component's componentDidUpdate.
|
2017-01-26 21:29:28 +00:00
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
2022-01-07 13:18:24 +00:00
|
|
|
async componentDidUpdate(prevProps: Props) {
|
2019-01-04 03:34:46 +00:00
|
|
|
const previousUrl = toURLString(prevProps.url);
|
|
|
|
const currentUrl = toURLString(this.props.url);
|
|
|
|
const previousTimestamp = prevProps.timestamp;
|
|
|
|
const currentTimestamp = this.props.timestamp;
|
2018-01-08 11:00:31 +00:00
|
|
|
|
2022-01-11 15:03:42 +00:00
|
|
|
await this._init.promise;
|
2017-07-06 18:27:00 +00:00
|
|
|
|
2022-01-07 13:18:24 +00:00
|
|
|
// Deal with URL changes.
|
2017-08-15 22:21:58 +00:00
|
|
|
|
2022-01-07 13:18:24 +00:00
|
|
|
if (previousUrl !== currentUrl
|
|
|
|
|
|
|
|
// XXX Refer to the implementation of loadURLObject: in
|
|
|
|
// ios/sdk/src/JitsiMeetView.m for further information.
|
|
|
|
|| previousTimestamp !== currentTimestamp) {
|
|
|
|
this._openURL(currentUrl || this._getDefaultURL());
|
|
|
|
}
|
2017-01-26 21:29:28 +00:00
|
|
|
}
|
|
|
|
|
2023-02-14 09:50:46 +00:00
|
|
|
_createMainElement: (React.ReactElement, Object) => ?React.ReactElement;
|
2017-01-26 21:29:28 +00:00
|
|
|
|
2017-01-15 19:05:17 +00:00
|
|
|
/**
|
2017-07-26 19:40:34 +00:00
|
|
|
* Gets the default URL to be opened when this {@code App} mounts.
|
2017-01-15 19:05:17 +00:00
|
|
|
*
|
2017-02-18 16:02:31 +00:00
|
|
|
* @protected
|
2017-07-26 19:40:34 +00:00
|
|
|
* @returns {string} The default URL to be opened when this {@code App}
|
|
|
|
* mounts.
|
2017-01-15 19:05:17 +00:00
|
|
|
*/
|
|
|
|
_getDefaultURL() {
|
2018-07-11 08:57:07 +00:00
|
|
|
return getDefaultURL(this.state.store);
|
2017-01-15 19:05:17 +00:00
|
|
|
}
|
|
|
|
|
2016-10-05 14:36:59 +00:00
|
|
|
/**
|
2018-11-08 12:25:02 +00:00
|
|
|
* Navigates this {@code AbstractApp} to (i.e. Opens) a specific URL.
|
2016-10-05 14:36:59 +00:00
|
|
|
*
|
2018-02-26 19:37:12 +00:00
|
|
|
* @param {Object|string} url - The URL to navigate this {@code AbstractApp}
|
2018-11-08 12:25:02 +00:00
|
|
|
* to (i.e. The URL to open).
|
2016-10-05 14:36:59 +00:00
|
|
|
* @protected
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_openURL(url) {
|
2018-07-10 14:42:22 +00:00
|
|
|
this.state.store.dispatch(appNavigate(toURLString(url)));
|
2016-10-05 14:36:59 +00:00
|
|
|
}
|
|
|
|
}
|