Skip to content

Commit

Permalink
feat: Reduces into state region and shard changes from the lib. (#14546)
Browse files Browse the repository at this point in the history
* feat: Reduces into state region and shard changes from the lib.

* squash: Fixes few comments.

* chore(deps) lib-jitsi-meet@latest

jitsi/lib-jitsi-meet@v1802.0.0+49ff6eb4...v1803.0.0+5237dbfe
  • Loading branch information
damencho authored Mar 26, 2024
1 parent 56eecab commit 2c6f4e2
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 7 deletions.
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"js-md5": "0.6.1",
"js-sha512": "0.8.0",
"jwt-decode": "2.2.0",
"lib-jitsi-meet": "https://github.com/jitsi/lib-jitsi-meet/releases/download/v1802.0.0+49ff6eb4/lib-jitsi-meet.tgz",
"lib-jitsi-meet": "https://github.com/jitsi/lib-jitsi-meet/releases/download/v1803.0.0+5237dbfe/lib-jitsi-meet.tgz",
"lodash": "4.17.21",
"moment": "2.29.4",
"moment-duration-format": "2.2.2",
Expand Down
19 changes: 19 additions & 0 deletions react/features/base/config/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import _ from 'lodash';
import { CONFERENCE_INFO } from '../../conference/components/constants';
import { TOOLBAR_BUTTONS } from '../../toolbox/constants';
import { ToolbarButton } from '../../toolbox/types';
import { CONNECTION_PROPERTIES_UPDATED } from '../connection/actionTypes';
import ReducerRegistry from '../redux/ReducerRegistry';
import { equals } from '../redux/functions';

Expand Down Expand Up @@ -94,6 +95,24 @@ ReducerRegistry.register<IConfigState>('features/base/config', (state = _getInit
locationURL: action.locationURL
};

case CONNECTION_PROPERTIES_UPDATED: {
const { region, shard } = action.properties;
const { deploymentInfo } = state;

if (deploymentInfo?.region === region && deploymentInfo?.shard === shard) {
return state;
}

return {
...state,
deploymentInfo: JSON.parse(JSON.stringify({
...deploymentInfo,
region,
shard
}))
};
}

case LOAD_CONFIG_ERROR:
// XXX LOAD_CONFIG_ERROR is one of the settlement execution paths of
// the asynchronous "loadConfig procedure/process" started with
Expand Down
10 changes: 10 additions & 0 deletions react/features/base/connection/actionTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ export const CONNECTION_ESTABLISHED = 'CONNECTION_ESTABLISHED';
*/
export const CONNECTION_FAILED = 'CONNECTION_FAILED';

/**
* The type of (redux) action which signals that connection properties were updated.
*
* {
* type: CONNECTION_PROPERTIES_UPDATED,
* properties: Object
* }
*/
export const CONNECTION_PROPERTIES_UPDATED = 'CONNECTION_PROPERTIES_UPDATED';

/**
* The type of (redux) action which signals that a connection will connect.
*
Expand Down
35 changes: 34 additions & 1 deletion react/features/base/connection/actions.any.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
CONNECTION_DISCONNECTED,
CONNECTION_ESTABLISHED,
CONNECTION_FAILED,
CONNECTION_PROPERTIES_UPDATED,
CONNECTION_WILL_CONNECT,
SET_LOCATION_URL,
SET_PREFER_VISITOR
Expand Down Expand Up @@ -230,6 +231,9 @@ export function _connectInternal(id?: string, password?: string) {
connection.addEventListener(
JitsiConnectionEvents.CONNECTION_REDIRECTED,
_onConnectionRedirected);
connection.addEventListener(
JitsiConnectionEvents.PROPERTIES_UPDATED,
_onPropertiesUpdate);

/**
* Unsubscribe the connection instance from
Expand All @@ -241,6 +245,7 @@ export function _connectInternal(id?: string, password?: string) {
connection.removeEventListener(
JitsiConnectionEvents.CONNECTION_DISCONNECTED, _onConnectionDisconnected);
connection.removeEventListener(JitsiConnectionEvents.CONNECTION_FAILED, _onConnectionFailed);
connection.removeEventListener(JitsiConnectionEvents.PROPERTIES_UPDATED, _onPropertiesUpdate);
}

/**
Expand Down Expand Up @@ -299,7 +304,7 @@ export function _connectInternal(id?: string, password?: string) {
}

/**
* Rejects external promise when connection fails.
* Connection was redirected.
*
* @param {string|undefined} vnode - The vnode to connect to.
* @param {string} focusJid - The focus jid to use.
Expand All @@ -313,6 +318,17 @@ export function _connectInternal(id?: string, password?: string) {
dispatch(redirect(vnode, focusJid, username));
}

/**
* Connection properties were updated.
*
* @param {Object} properties - The properties which were updated.
* @private
* @returns {void}
*/
function _onPropertiesUpdate(properties: object) {
dispatch(_propertiesUpdate(properties));
}

// in case of configured http url for conference request we need the room name
const name = getBackendSafeRoomName(state['features/base/conference'].room);

Expand Down Expand Up @@ -343,6 +359,23 @@ function _connectionWillConnect(connection: Object) {
};
}

/**
* Create an action for when connection properties are updated.
*
* @param {Object} properties - The properties which were updated.
* @private
* @returns {{
* type: CONNECTION_PROPERTIES_UPDATED,
* properties: Object
* }}
*/
function _propertiesUpdate(properties: object) {
return {
type: CONNECTION_PROPERTIES_UPDATED,
properties
};
}

/**
* Closes connection.
*
Expand Down

0 comments on commit 2c6f4e2

Please sign in to comment.