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