Skip to content

Commit

Permalink
ref(initialGUMPromise): Move out of _common reducer.
Browse files Browse the repository at this point in the history
  • Loading branch information
hristoterezov committed Jul 30, 2024
1 parent 1de1381 commit d510390
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 19 deletions.
4 changes: 2 additions & 2 deletions react/features/base/conference/middleware.web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ MiddlewareRegistry.register(store => next => action => {

break;
case CONNECTION_DISCONNECTED: {
const { initialGUMPromise } = getState()['features/base/media'].common;
const { initialGUMPromise } = getState()['features/base/media'];

if (initialGUMPromise) {
store.dispatch(setInitialGUMPromise());
Expand All @@ -150,7 +150,7 @@ MiddlewareRegistry.register(store => next => action => {
const state = getState();

if (!isPrejoinPageVisible(state)) {
const { initialGUMPromise = Promise.resolve({ tracks: [] }) } = state['features/base/media'].common;
const { initialGUMPromise = Promise.resolve({ tracks: [] }) } = state['features/base/media'];

initialGUMPromise.then(({ tracks }) => {
let tracksToUse = tracks ?? [];
Expand Down
22 changes: 6 additions & 16 deletions react/features/base/media/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,6 @@ function _audio(state: IAudioState = _AUDIO_INITIAL_MEDIA_STATE, action: AnyActi
}
}

/**
* The initial common media state.
*/
const _COMMON_INITIAL_STATE = {};

/**
* Reducer fot the common properties in media state.
*
Expand All @@ -101,12 +96,9 @@ const _COMMON_INITIAL_STATE = {};
* @param {string} action.type - Type of action.
* @returns {ICommonState}
*/
function _common(state: ICommonState = _COMMON_INITIAL_STATE, action: AnyAction) {
function _initialGUMPromise(state: initialGUMPromise | undefined, action: AnyAction) {
if (action.type === SET_INITIAL_GUM_PROMISE) {
return {
...state,
initialGUMPromise: action.promise
};
return action.promise;
}

return state;
Expand Down Expand Up @@ -272,12 +264,10 @@ interface IAudioState {
unmuteBlocked: boolean;
}

interface ICommonState {
initialGUMPromise?: Promise<{
type initialGUMPromise = Promise<{
errors: any;
tracks: Array<any>;
}>;
}
}> | undefined;

interface IScreenshareState {
available: boolean;
Expand All @@ -296,7 +286,7 @@ interface IVideoState {

export interface IMediaState {
audio: IAudioState;
common: ICommonState;
initialGUMPromise: initialGUMPromise;
screenshare: IScreenshareState;
video: IVideoState;
}
Expand All @@ -313,7 +303,7 @@ export interface IMediaState {
*/
ReducerRegistry.register<IMediaState>('features/base/media', combineReducers({
audio: _audio,
common: _common,
initialGUMPromise: _initialGUMPromise,
screenshare: _screenshare,
video: _video
}));
Expand Down
2 changes: 1 addition & 1 deletion react/features/prejoin/middleware.web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ MiddlewareRegistry.register(store => next => action => {
const result = next(action);

if (isPrejoinPageVisible(getState())) {
const { initialGUMPromise = Promise.resolve() } = getState()['features/base/media'].common;
const { initialGUMPromise = Promise.resolve() } = getState()['features/base/media'];

initialGUMPromise.then(() => {
const state = getState();
Expand Down

0 comments on commit d510390

Please sign in to comment.