2022-09-23 09:03:25 +00:00
|
|
|
/* eslint-disable lines-around-comment */
|
|
|
|
// @ts-ignore
|
2020-09-25 22:51:54 +00:00
|
|
|
import { jitsiLocalStorage } from '@jitsi/js-utils';
|
2017-02-16 19:57:39 +00:00
|
|
|
|
2022-09-23 09:03:25 +00:00
|
|
|
import { IStore } from '../../app/types';
|
2020-03-30 13:50:26 +00:00
|
|
|
import { isOnline } from '../net-info/selectors';
|
|
|
|
|
2022-09-23 09:03:25 +00:00
|
|
|
// @ts-ignore
|
2017-02-28 03:21:50 +00:00
|
|
|
import JitsiMeetJS from './_';
|
2016-10-05 14:36:59 +00:00
|
|
|
import {
|
2017-02-27 22:45:53 +00:00
|
|
|
LIB_DID_DISPOSE,
|
|
|
|
LIB_DID_INIT,
|
2016-10-05 14:36:59 +00:00
|
|
|
LIB_INIT_ERROR,
|
2017-02-27 22:45:53 +00:00
|
|
|
LIB_WILL_DISPOSE,
|
core: refactor routing
Unfortunately, as the Jitsi Meet development evolved the routing mechanism
became more complex and thre logic ended up spread across multiple parts of the
codebase, which made it hard to follow and extend.
This change aims to fix that by rewriting the routing logic and centralizing it
in (pretty much) a single place, with no implicit inter-dependencies.
In order to arrive there, however, some extra changes were needed, which were
not caught early enough and are thus part of this change:
- JitsiMeetJS initialization is now synchronous: there is nothing async about
it, and the only async requirement (Temasys support) was lifted. See [0].
- WebRTC support can be detected early: building on top of the above, WebRTC
support can now be detected immediately, so take advantage of this to simplify
how we handle unsupported browsers. See [0].
The new router takes decissions based on the Redux state at the time of
invocation. A route can be represented by either a component or a URl reference,
with the latter taking precedence. On mobile, obviously, there is no concept of
URL reference so routing is based solely on components.
[0]: https://github.com/jitsi/lib-jitsi-meet/pull/779
2018-06-29 07:58:31 +00:00
|
|
|
LIB_WILL_INIT
|
2016-10-05 14:36:59 +00:00
|
|
|
} from './actionTypes';
|
2022-09-23 09:03:25 +00:00
|
|
|
// @ts-ignore
|
2017-09-01 19:14:03 +00:00
|
|
|
import { isAnalyticsEnabled } from './functions';
|
2016-10-05 14:36:59 +00:00
|
|
|
|
|
|
|
/**
|
2017-02-27 22:45:53 +00:00
|
|
|
* Disposes (of) lib-jitsi-meet.
|
2016-10-05 14:36:59 +00:00
|
|
|
*
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
export function disposeLib() {
|
2022-09-23 09:03:25 +00:00
|
|
|
return (dispatch: IStore['dispatch']) => {
|
2017-02-27 22:45:53 +00:00
|
|
|
dispatch({ type: LIB_WILL_DISPOSE });
|
2016-10-05 14:36:59 +00:00
|
|
|
|
2017-02-27 22:45:53 +00:00
|
|
|
// TODO Currently, lib-jitsi-meet doesn't have the functionality to
|
|
|
|
// dispose itself.
|
2017-05-17 21:44:28 +00:00
|
|
|
dispatch({ type: LIB_DID_DISPOSE });
|
2016-10-05 14:36:59 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-02-27 22:45:53 +00:00
|
|
|
* Initializes lib-jitsi-meet (i.e. {@link invokes JitsiMeetJS.init()}) with the
|
|
|
|
* current config(uration).
|
2016-10-05 14:36:59 +00:00
|
|
|
*
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
export function initLib() {
|
2022-09-23 09:03:25 +00:00
|
|
|
return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
|
2020-03-30 13:50:26 +00:00
|
|
|
const state = getState();
|
|
|
|
const config = state['features/base/config'];
|
2016-10-05 14:36:59 +00:00
|
|
|
|
|
|
|
if (!config) {
|
2017-02-24 19:08:49 +00:00
|
|
|
throw new Error('Cannot init lib-jitsi-meet without config');
|
2016-10-05 14:36:59 +00:00
|
|
|
}
|
|
|
|
|
2017-02-27 22:45:53 +00:00
|
|
|
dispatch({ type: LIB_WILL_INIT });
|
2016-10-05 14:36:59 +00:00
|
|
|
|
core: refactor routing
Unfortunately, as the Jitsi Meet development evolved the routing mechanism
became more complex and thre logic ended up spread across multiple parts of the
codebase, which made it hard to follow and extend.
This change aims to fix that by rewriting the routing logic and centralizing it
in (pretty much) a single place, with no implicit inter-dependencies.
In order to arrive there, however, some extra changes were needed, which were
not caught early enough and are thus part of this change:
- JitsiMeetJS initialization is now synchronous: there is nothing async about
it, and the only async requirement (Temasys support) was lifted. See [0].
- WebRTC support can be detected early: building on top of the above, WebRTC
support can now be detected immediately, so take advantage of this to simplify
how we handle unsupported browsers. See [0].
The new router takes decissions based on the Redux state at the time of
invocation. A route can be represented by either a component or a URl reference,
with the latter taking precedence. On mobile, obviously, there is no concept of
URL reference so routing is based solely on components.
[0]: https://github.com/jitsi/lib-jitsi-meet/pull/779
2018-06-29 07:58:31 +00:00
|
|
|
try {
|
|
|
|
JitsiMeetJS.init({
|
|
|
|
enableAnalyticsLogging: isAnalyticsEnabled(getState),
|
2020-09-25 22:51:54 +00:00
|
|
|
...config,
|
|
|
|
externalStorage: jitsiLocalStorage.isLocalStorageDisabled() ? jitsiLocalStorage : undefined
|
core: refactor routing
Unfortunately, as the Jitsi Meet development evolved the routing mechanism
became more complex and thre logic ended up spread across multiple parts of the
codebase, which made it hard to follow and extend.
This change aims to fix that by rewriting the routing logic and centralizing it
in (pretty much) a single place, with no implicit inter-dependencies.
In order to arrive there, however, some extra changes were needed, which were
not caught early enough and are thus part of this change:
- JitsiMeetJS initialization is now synchronous: there is nothing async about
it, and the only async requirement (Temasys support) was lifted. See [0].
- WebRTC support can be detected early: building on top of the above, WebRTC
support can now be detected immediately, so take advantage of this to simplify
how we handle unsupported browsers. See [0].
The new router takes decissions based on the Redux state at the time of
invocation. A route can be represented by either a component or a URl reference,
with the latter taking precedence. On mobile, obviously, there is no concept of
URL reference so routing is based solely on components.
[0]: https://github.com/jitsi/lib-jitsi-meet/pull/779
2018-06-29 07:58:31 +00:00
|
|
|
});
|
2020-03-30 13:50:26 +00:00
|
|
|
JitsiMeetJS.setNetworkInfo({
|
|
|
|
isOnline: isOnline(state)
|
|
|
|
});
|
core: refactor routing
Unfortunately, as the Jitsi Meet development evolved the routing mechanism
became more complex and thre logic ended up spread across multiple parts of the
codebase, which made it hard to follow and extend.
This change aims to fix that by rewriting the routing logic and centralizing it
in (pretty much) a single place, with no implicit inter-dependencies.
In order to arrive there, however, some extra changes were needed, which were
not caught early enough and are thus part of this change:
- JitsiMeetJS initialization is now synchronous: there is nothing async about
it, and the only async requirement (Temasys support) was lifted. See [0].
- WebRTC support can be detected early: building on top of the above, WebRTC
support can now be detected immediately, so take advantage of this to simplify
how we handle unsupported browsers. See [0].
The new router takes decissions based on the Redux state at the time of
invocation. A route can be represented by either a component or a URl reference,
with the latter taking precedence. On mobile, obviously, there is no concept of
URL reference so routing is based solely on components.
[0]: https://github.com/jitsi/lib-jitsi-meet/pull/779
2018-06-29 07:58:31 +00:00
|
|
|
dispatch({ type: LIB_DID_INIT });
|
2022-09-23 09:03:25 +00:00
|
|
|
} catch (error: any) {
|
core: refactor routing
Unfortunately, as the Jitsi Meet development evolved the routing mechanism
became more complex and thre logic ended up spread across multiple parts of the
codebase, which made it hard to follow and extend.
This change aims to fix that by rewriting the routing logic and centralizing it
in (pretty much) a single place, with no implicit inter-dependencies.
In order to arrive there, however, some extra changes were needed, which were
not caught early enough and are thus part of this change:
- JitsiMeetJS initialization is now synchronous: there is nothing async about
it, and the only async requirement (Temasys support) was lifted. See [0].
- WebRTC support can be detected early: building on top of the above, WebRTC
support can now be detected immediately, so take advantage of this to simplify
how we handle unsupported browsers. See [0].
The new router takes decissions based on the Redux state at the time of
invocation. A route can be represented by either a component or a URl reference,
with the latter taking precedence. On mobile, obviously, there is no concept of
URL reference so routing is based solely on components.
[0]: https://github.com/jitsi/lib-jitsi-meet/pull/779
2018-06-29 07:58:31 +00:00
|
|
|
dispatch(libInitError(error));
|
|
|
|
}
|
2016-10-05 14:36:59 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-02-24 19:08:49 +00:00
|
|
|
/**
|
|
|
|
* Notifies about a specific error raised by {@link JitsiMeetJS.init()}.
|
|
|
|
*
|
|
|
|
* @param {Error} error - The Error raised by JitsiMeetJS.init().
|
|
|
|
* @returns {{
|
|
|
|
* type: LIB_INIT_ERROR,
|
|
|
|
* error: Error
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
export function libInitError(error: Error) {
|
|
|
|
return {
|
|
|
|
type: LIB_INIT_ERROR,
|
|
|
|
error
|
|
|
|
};
|
|
|
|
}
|