Skip to content

Commit

Permalink
feat(prejoin): make initPrejoin sync.
Browse files Browse the repository at this point in the history
  • Loading branch information
hristoterezov committed Jul 25, 2024
1 parent c602d77 commit ccf6c9a
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 40 deletions.
5 changes: 2 additions & 3 deletions conference.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,7 @@ import {
import { isModerationNotificationDisplayed } from './react/features/notifications/functions';
import { mediaPermissionPromptVisibilityChanged } from './react/features/overlay/actions';
import { suspendDetected } from './react/features/power-monitor/actions';
import { initPrejoin } from './react/features/prejoin/actions';
import { isPrejoinPageVisible } from './react/features/prejoin/functions';
import { initPrejoin, isPrejoinPageVisible } from './react/features/prejoin/functions';
import { disableReceiver, stopReceiver } from './react/features/remote-control/actions';
import { setScreenAudioShareState } from './react/features/screen-share/actions.web';
import { isScreenAudioShared } from './react/features/screen-share/functions';
Expand Down Expand Up @@ -618,7 +617,7 @@ export default {

// Note: Not sure if initPrejoin needs to be async. But let's wait for it just to be sure the
// tracks are added.
await dispatch(initPrejoin(tracks, errors));
initPrejoin(tracks, errors, dispatch);
} else {
APP.store.dispatch(displayErrorsForCreateInitialLocalTracks(errors));
setGUMPendingStateOnFailedTracks(tracks, APP.store.dispatch);
Expand Down
33 changes: 2 additions & 31 deletions react/features/prejoin/actions.web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { connect } from '../base/connection/actions';
import { createLocalTrack } from '../base/lib-jitsi-meet/functions';
import { isVideoMutedByUser } from '../base/media/functions';
import { updateSettings } from '../base/settings/actions';
import { replaceLocalTrack, trackAdded } from '../base/tracks/actions';
import { replaceLocalTrack } from '../base/tracks/actions';
import {
createLocalTracksF,
getLocalAudioTrack,
Expand All @@ -20,7 +20,6 @@ import { NOTIFICATION_TIMEOUT_TYPE } from '../notifications/constants';
import { INotificationProps } from '../notifications/types';

import {
PREJOIN_INITIALIZED,
PREJOIN_JOINING_IN_PROGRESS,
SET_DEVICE_STATUS,
SET_DIALOUT_COUNTRY,
Expand All @@ -36,7 +35,7 @@ import {
getDialOutCountry,
getFullDialOutNumber,
isJoinByPhoneDialogVisible
} from './functions';
} from './functions.any';
import logger from './logger';

const dialOutStatusToKeyMap = {
Expand Down Expand Up @@ -185,23 +184,6 @@ export function dialOut(onSuccess: Function, onFail: Function) {
};
}

/**
* Adds all the newly created tracks to store on init.
*
* @param {Object[]} tracks - The newly created tracks.
* @param {Object} errors - The errors from creating the tracks.
*
* @returns {Function}
*/
export function initPrejoin(tracks: Object[], errors: Object) {
return function(dispatch: IStore['dispatch']) {
dispatch(setPrejoinDeviceErrors(errors));
dispatch(prejoinInitialized());

tracks.forEach(track => dispatch(trackAdded(track)));
};
}

/**
* Action used to start the conference.
*
Expand Down Expand Up @@ -294,17 +276,6 @@ export function openDialInPage() {
};
}

/**
* Action used to signal that the prejoin page has been initialized.
*
* @returns {Object}
*/
function prejoinInitialized() {
return {
type: PREJOIN_INITIALIZED
};
}

/**
* Creates a new audio track based on a device id and replaces the current one.
*
Expand Down
7 changes: 2 additions & 5 deletions react/features/prejoin/components/web/PrejoinApp.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { ComponentType } from 'react';
import { batch } from 'react-redux';

import BaseApp from '../../../base/app/components/BaseApp';
import { setConfig } from '../../../base/config/actions';
Expand All @@ -8,7 +7,7 @@ import GlobalStyles from '../../../base/ui/components/GlobalStyles.web';
import JitsiThemeProvider from '../../../base/ui/components/JitsiThemeProvider.web';
import DialogContainer from '../../../base/ui/components/web/DialogContainer';
import { setupInitialDevices } from '../../../conference/actions.web';
import { initPrejoin } from '../../actions.web';
import { initPrejoin } from '../../functions.web';

import PrejoinThirdParty from './PrejoinThirdParty';

Expand Down Expand Up @@ -64,9 +63,7 @@ export default class PrejoinApp extends BaseApp<Props> {

const tracks = await tryCreateLocalTracks;

batch(() => {
dispatch?.(initPrejoin(tracks, errors));
});
initPrejoin(tracks, errors, dispatch);
}

/**
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions react/features/prejoin/functions.native.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './functions.any';
32 changes: 32 additions & 0 deletions react/features/prejoin/functions.web.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { batch } from 'react-redux';

import { IStore } from '../app/types';
import { trackAdded } from '../base/tracks/actions.any';

import { PREJOIN_INITIALIZED } from './actionTypes';
import { setPrejoinDeviceErrors } from './actions.web';

export * from './functions.any';

/**
* Adds all the newly created tracks to store on init.
*
* @param {Object[]} tracks - The newly created tracks.
* @param {Object} errors - The errors from creating the tracks.
* @param {Function} dispatch - The redux dispatch function.
* @returns {void}
*/
export function initPrejoin(tracks: Object[], errors: Object, dispatch?: IStore['dispatch']) {
if (!dispatch) {
return;
}

batch(() => {
dispatch(setPrejoinDeviceErrors(errors));
dispatch({
type: PREJOIN_INITIALIZED
});

tracks.forEach(track => dispatch(trackAdded(track)));
});
}
2 changes: 1 addition & 1 deletion react/features/prejoin/middleware.web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
setDeviceStatusWarning,
setJoiningInProgress
} from './actions';
import { isPrejoinPageVisible } from './functions';
import { isPrejoinPageVisible } from './functions.any';
import logger from './logger';

/**
Expand Down

0 comments on commit ccf6c9a

Please sign in to comment.