-
Notifications
You must be signed in to change notification settings - Fork 7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eeca7c7
commit b245802
Showing
3 changed files
with
112 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* global APP, config */ | ||
import ConferenceUrl from '../../../modules/URL/ConferenceUrl'; | ||
import BoshAddressChoice from '../../../modules/config/BoshAddressChoice'; | ||
import { obtainConfig, setTokenData } from './functions'; | ||
const logger = require('jitsi-meet-logger').getLogger(__filename); | ||
|
||
/** | ||
* If we have an HTTP endpoint for getting config.json configured | ||
* we're going to read it and override properties from config.js and | ||
* interfaceConfig.js. If there is no endpoint we'll just | ||
* continue with initialization. | ||
* Keep in mind that if the endpoint has been configured and we fail | ||
* to obtain the config for any reason then the conference won't | ||
* start and error message will be displayed to the user. | ||
* | ||
* @returns {Function} | ||
*/ | ||
export function obtainConfigAndInit() { | ||
return () => { | ||
const room = APP.conference.roomName; | ||
|
||
if (config.configLocation) { | ||
const location = config.configLocation; | ||
|
||
obtainConfig(location, room) | ||
.then(_obtainConfigHandler) | ||
.then(_initConference) | ||
.catch(err => { | ||
// Show obtain config error, | ||
// pass the error object for report | ||
APP.UI.messageHandler.openReportDialog( | ||
null, 'dialog.connectError', err); | ||
}); | ||
} else { | ||
BoshAddressChoice.chooseAddress(config, room); | ||
_initConference(); | ||
} | ||
}; | ||
} | ||
|
||
/** | ||
* Obtain config handler. | ||
* | ||
* @returns {Promise} | ||
* @private | ||
*/ | ||
function _obtainConfigHandler() { | ||
const now = window.performance.now(); | ||
|
||
APP.connectionTimes['configuration.fetched'] = now; | ||
logger.log('(TIME) configuration fetched:\t', now); | ||
|
||
return Promise.resolve(); | ||
} | ||
|
||
/** | ||
* Initialization of the app. | ||
* | ||
* @returns {void} | ||
* @private | ||
*/ | ||
function _initConference() { | ||
setTokenData(); | ||
|
||
// Initialize the conference URL handler | ||
APP.ConferenceUrl = new ConferenceUrl(window.location); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* global APP */ | ||
import HttpConfigFetch from '../../../modules/config/HttpConfigFetch'; | ||
|
||
/** | ||
* Promise wrapper on obtain config method. | ||
* When HttpConfigFetch will be moved to React app | ||
* it's better to use load config instead. | ||
* | ||
* @param {string} location - URL of the domain. | ||
* @param {string} room - Room name. | ||
* @returns {Promise} | ||
*/ | ||
export function obtainConfig(location, room) { | ||
return new Promise((resolve, reject) => { | ||
HttpConfigFetch.obtainConfig(location, room, (success, error) => { | ||
if (success) { | ||
resolve(); | ||
} else { | ||
reject(error); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
/** | ||
* If JWT token data it will be used for local user settings. | ||
* | ||
* @returns {void} | ||
*/ | ||
export function setTokenData() { | ||
const localUser = APP.tokenData.caller; | ||
|
||
if (localUser) { | ||
const email = localUser.getEmail(); | ||
const avatarUrl = localUser.getAvatarUrl(); | ||
const name = localUser.getName(); | ||
|
||
APP.settings.setEmail((email || '').trim(), true); | ||
APP.settings.setAvatarUrl((avatarUrl || '').trim()); | ||
APP.settings.setDisplayName((name || '').trim(), true); | ||
} | ||
} |