Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(base/conference): get subject and localSubject from config #14520

Merged
merged 8 commits into from
Mar 26, 2024
2 changes: 1 addition & 1 deletion react/features/app/actions.native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export function appNavigate(uri?: string, options: IReloadNowOptions = {}) {
}

dispatch(setLocationURL(locationURL));
dispatch(setConfig(config));
dispatch(setConfig(config, locationURL));
dispatch(setRoom(room));

if (!room) {
Expand Down
10 changes: 8 additions & 2 deletions react/features/base/conference/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,18 @@ export function forEachConference(
export function getConferenceName(stateful: IStateful): string {
const state = toState(stateful);
const { callee } = state['features/base/jwt'];
const { callDisplayName } = state['features/base/config'];
const {
callDisplayName,
localSubject: configLocalSubject,
subject: configSubject
} = state['features/base/config'];
const { localSubject, pendingSubjectChange, room, subject } = getConferenceState(state);

return (pendingSubjectChange
|| localSubject
|| configSubject
|| subject
|| configLocalSubject
|| localSubject
|| callDisplayName
|| callee?.name
|| (room && safeStartCase(safeDecodeURIComponent(room)))) ?? '';
Expand Down
4 changes: 2 additions & 2 deletions react/features/base/conference/middleware.any.ts
Original file line number Diff line number Diff line change
Expand Up @@ -592,8 +592,8 @@ function _setRoom({ dispatch, getState }: IStore, next: Function, action: AnyAct

if (room) {
// Set the stored subject.
dispatch(setLocalSubject(localSubject ?? ''));
dispatch(setSubject(subject ?? ''));
subject && dispatch(setLocalSubject(localSubject));
localSubject && dispatch(setSubject(subject));
}

return next(action);
Expand Down
84 changes: 41 additions & 43 deletions react/features/base/config/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,53 +96,51 @@ export function overwriteConfig(config: Object) {
*
* @param {Object} config - The configuration to be represented by the feature
* base/config.
* @param {URL} locationURL - The URL of the location which necessitated the
* loading of a configuration.
* @returns {Function}
*/
export function setConfig(config: IConfig = {}) {
return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
const { locationURL } = getState()['features/base/connection'];

// Now that the loading of the config was successful override the values
// with the parameters passed in the hash part of the location URI.
// TODO We're still in the middle ground between old Web with config,
// and interfaceConfig used via global variables and new
// Web and mobile reading the respective values from the redux store.
// Only the config will be overridden on React Native, as the other
// globals will be undefined here. It's intentional - we do not care to
// override those configs yet.
locationURL
&& setConfigFromURLParams(

// On Web the config also comes from the window.config global,
// but it is resolved in the loadConfig procedure.
config,
window.interfaceConfig,
locationURL);

let { bosh } = config;

if (bosh) {
// Normalize the BOSH URL.
if (bosh.startsWith('//')) {
// By default our config.js doesn't include the protocol.
bosh = `${locationURL?.protocol}${bosh}`;
} else if (bosh.startsWith('/')) {
// Handle relative URLs, which won't work on mobile.
const {
protocol,
host,
contextRoot
} = parseURIString(locationURL?.href);

bosh = `${protocol}//${host}${contextRoot || '/'}${bosh.substr(1)}`;
}
config.bosh = bosh;
export function setConfig(config: IConfig = {}, locationURL: URL) {
// Now that the loading of the config was successful override the values
// with the parameters passed in the hash part of the location URI.
// TODO We're still in the middle ground between old Web with config,
// and interfaceConfig used via global variables and new
// Web and mobile reading the respective values from the redux store.
// Only the config will be overridden on React Native, as the other
// globals will be undefined here. It's intentional - we do not care to
// override those configs yet.
locationURL
&& setConfigFromURLParams(

// On Web the config also comes from the window.config global,
// but it is resolved in the loadConfig procedure.
config,
window.interfaceConfig,
locationURL);

let { bosh } = config;

if (bosh) {
// Normalize the BOSH URL.
if (bosh.startsWith('//')) {
// By default our config.js doesn't include the protocol.
bosh = `${locationURL?.protocol}${bosh}`;
} else if (bosh.startsWith('/')) {
// Handle relative URLs, which won't work on mobile.
const {
protocol,
host,
contextRoot
} = parseURIString(locationURL?.href);

bosh = `${protocol}//${host}${contextRoot || '/'}${bosh.substr(1)}`;
}
config.bosh = bosh;
}

dispatch({
type: SET_CONFIG,
config
});
return {
type: SET_CONFIG,
config
};
}

Expand Down
5 changes: 4 additions & 1 deletion react/features/base/util/parseURLParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,12 @@
value = param[1];

if (!dontParse) {
const decoded = decodeURIComponent(value).replace(/\\&/, '&');
const decoded = decodeURIComponent(value).replace(/\\&/, '&')
.replace(/[\u2018\u2019]/g, "'")

Check failure on line 64 in react/features/base/util/parseURLParams.ts

View workflow job for this annotation

GitHub Actions / Lint

Strings must use singlequote
Calinteodor marked this conversation as resolved.
Show resolved Hide resolved
.replace(/[\u201C\u201D]/g, '"');

value = decoded === 'undefined' ? undefined : safeJsonParse(decoded);

}
} catch (e: any) {
reportError(
Expand Down
Loading