fix(subject) Fix setting and broadcasting subject (#14807)

This commit is contained in:
Horatiu Muresan
2024-06-07 16:19:36 +03:00
committed by GitHub
parent 0368b4d671
commit befffa7e85
7 changed files with 73 additions and 59 deletions

View File

@@ -151,7 +151,7 @@ export function appNavigate(uri?: string, options: IReloadNowOptions = {}) {
}
dispatch(setLocationURL(locationURL));
dispatch(setConfig(config, locationURL));
dispatch(setConfig(config));
dispatch(setRoom(room));
if (!room) {

View File

@@ -74,7 +74,7 @@ export function appNavigate(uri?: string) {
const config = await loadConfig();
dispatch(setLocationURL(locationURL));
dispatch(setConfig(config, locationURL));
dispatch(setConfig(config));
dispatch(setRoom(room));
};
}

View File

@@ -984,12 +984,12 @@ export function setStartMutedPolicy(
* @param {string} subject - The new subject.
* @returns {void}
*/
export function setSubject(subject: string | undefined) {
export function setSubject(subject: string) {
return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
const { conference } = getState()['features/base/conference'];
if (conference) {
conference.setSubject(subject || '');
conference.setSubject(subject);
} else {
dispatch({
type: SET_PENDING_SUBJECT_CHANGE,
@@ -1008,7 +1008,7 @@ export function setSubject(subject: string | undefined) {
* localSubject: string
* }}
*/
export function setLocalSubject(localSubject: string | undefined) {
export function setLocalSubject(localSubject: string) {
return {
type: CONFERENCE_LOCAL_SUBJECT_CHANGED,
localSubject

View File

@@ -185,18 +185,12 @@ export function forEachConference(
export function getConferenceName(stateful: IStateful): string {
const state = toState(stateful);
const { callee } = state['features/base/jwt'];
const {
callDisplayName,
localSubject: configLocalSubject,
subject: configSubject
} = state['features/base/config'];
const { callDisplayName } = state['features/base/config'];
const { localSubject, pendingSubjectChange, room, subject } = getConferenceState(state);
return (pendingSubjectChange
|| configSubject
return (localSubject
|| pendingSubjectChange
|| subject
|| configLocalSubject
|| localSubject
|| callDisplayName
|| callee?.name
|| (room && safeStartCase(safeDecodeURIComponent(room)))) ?? '';

View File

@@ -3,6 +3,8 @@ import { AnyAction } from 'redux';
import { FaceLandmarks } from '../../face-landmarks/types';
import { LOCKED_LOCALLY, LOCKED_REMOTELY } from '../../room-lock/constants';
import { ISpeakerStats } from '../../speaker-stats/reducer';
import { SET_CONFIG } from '../config/actionTypes';
import { IConfig } from '../config/configType';
import { CONNECTION_WILL_CONNECT, SET_LOCATION_URL } from '../connection/actionTypes';
import { JitsiConferenceErrors } from '../lib-jitsi-meet';
import ReducerRegistry from '../redux/ReducerRegistry';
@@ -278,11 +280,33 @@ ReducerRegistry.register<IConferenceState>('features/base/conference',
...state,
metadata: action.metadata
};
case SET_CONFIG:
return _setConfig(state, action);
}
return state;
});
/**
* Processes subject and local subject of the conference based on the new config.
*
* @param {Object} state - The Redux state of feature base/conference.
* @param {Action} action - The Redux action SET_CONFIG to reduce.
* @private
* @returns {Object} The new state after the reduction of the specified action.
*/
function _setConfig(state: IConferenceState, { config }: { config: IConfig; }) {
const { localSubject, subject } = config;
return {
...state,
localSubject,
pendingSubjectChange: subject,
subject: undefined
};
}
/**
* Reduces a specific Redux action AUTH_STATUS_CHANGED of the feature
* base/conference.
@@ -606,10 +630,7 @@ function _setRoom(state: IConferenceState, action: AnyAction) {
*/
return assign(state, {
error: undefined,
localSubject: undefined,
pendingSubjectChange: undefined,
room,
subject: undefined
room
});
}

View File

@@ -96,51 +96,53 @@ 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 = {}, locationURL: URL | undefined) {
// 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(
export function setConfig(config: IConfig = {}) {
return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
const { locationURL } = getState()['features/base/connection'];
// On Web the config also comes from the window.config global,
// but it is resolved in the loadConfig procedure.
config,
window.interfaceConfig,
locationURL);
// 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(
let { bosh } = config;
// On Web the config also comes from the window.config global,
// but it is resolved in the loadConfig procedure.
config,
window.interfaceConfig,
locationURL);
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);
let { bosh } = config;
bosh = `${protocol}//${host}${contextRoot || '/'}${bosh.substr(1)}`;
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;
}
config.bosh = bosh;
}
return {
type: SET_CONFIG,
config
dispatch({
type: SET_CONFIG,
config
});
};
}

View File

@@ -50,9 +50,6 @@ export default class PrejoinApp extends BaseApp<Props> {
? store.getState()['features/base/settings']
: { startWithAudioMuted: undefined,
startWithVideoMuted: undefined };
const { locationURL } = store
? store.getState()['features/base/connection']
: { locationURL: undefined };
dispatch?.(setConfig({
prejoinConfig: {
@@ -60,7 +57,7 @@ export default class PrejoinApp extends BaseApp<Props> {
},
startWithAudioMuted,
startWithVideoMuted
}, locationURL));
}));
await dispatch?.(setupInitialDevices());
const { tryCreateLocalTracks, errors } = createPrejoinTracks();