Files
jitsi-meet/react/features/video-layout/middleware.web.ts
Дамян Минков bc23f9cd33 feat: Drops connection on prejoin screen. (#13538)
* feat: Drops connection on prejoin screen.

Refactors connection logic to reuse already existing logic from mobile. Connection is now established just before joining the room.
Fixes some authentication logic with Login and Logout button in Profile tab.

* squash: Drops createInitialLocalTracksAndConnect as it no longer connects.

* squash: Shows an error on mobile and redirects to default.

* squash: Fixes review comments.

* squash: Fixes joining with prejoin disabled.

* squash: Fixes adding initial local tracks.

* squash: Fixes comments.

* squash: Drop no longer used method.

* squash: Fixes old web code imported into mobile builds.

* squash: Drop unused prop.

* squash: Drops recoverable flag on REDIRECT.

* squash: Drops unused variable and fix connection access.

* squash: Xmpp connect returns promise again.

* squash: Execute xmpp connect and creating local tracks in parallel.

* squash: Moves notification about problem jwt.

* squash: Moves startConference to conference.js for the no prejoin case.

And move the startConference in prejoin feature for the prejoin case.

* squash: Fix passing filtered tracks when starting conference with no prejoin.

* squash: Fix clearing listeners on connection established.

Keeps mobile behaviour after merging web and mobile.

* squash: Drops unused code.
2023-07-15 17:33:26 -05:00

73 lines
2.5 KiB
TypeScript

// @ts-expect-error
import VideoLayout from '../../../modules/UI/videolayout/VideoLayout.js';
import { CONFERENCE_WILL_INIT, CONFERENCE_WILL_LEAVE } from '../base/conference/actionTypes';
import { MEDIA_TYPE } from '../base/media/constants';
import { PARTICIPANT_JOINED } from '../base/participants/actionTypes';
import { getLocalParticipant } from '../base/participants/functions';
import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
import { TRACK_ADDED, TRACK_REMOVED, TRACK_STOPPED } from '../base/tracks/actionTypes';
import { PARTICIPANTS_PANE_CLOSE, PARTICIPANTS_PANE_OPEN } from '../participants-pane/actionTypes';
import './middleware.any';
/**
* Middleware which intercepts actions and updates the legacy component
* {@code VideoLayout} as needed. The purpose of this middleware is to redux-ify
* {@code VideoLayout} without having to simultaneously react-ifying it.
*
* @param {Store} store - The redux store.
* @returns {Function}
*/
// eslint-disable-next-line no-unused-vars
MiddlewareRegistry.register(store => next => action => {
// Purposefully perform additional actions after state update to mimic
// being connected to the store for updates.
const result = next(action);
switch (action.type) {
case CONFERENCE_WILL_INIT:
// Reset VideoLayout. It's destroyed on CONFERENCE_WILL_LEAVE so re-initialize it.
VideoLayout.initLargeVideo();
VideoLayout.resizeVideoArea();
break;
case CONFERENCE_WILL_LEAVE:
VideoLayout.reset();
break;
case PARTICIPANT_JOINED:
if (!action.participant.local) {
VideoLayout.updateVideoMutedForNoTracks(action.participant.id);
}
break;
case PARTICIPANTS_PANE_CLOSE:
case PARTICIPANTS_PANE_OPEN:
VideoLayout.resizeVideoArea();
break;
case TRACK_ADDED:
if (action.track.mediaType !== MEDIA_TYPE.AUDIO) {
VideoLayout._updateLargeVideoIfDisplayed(action.track.participantId, true);
}
break;
case TRACK_STOPPED: {
if (action.track.jitsiTrack.isLocal()) {
const participant = getLocalParticipant(store.getState);
VideoLayout._updateLargeVideoIfDisplayed(participant?.id);
}
break;
}
case TRACK_REMOVED:
if (!action.track.local && action.track.mediaType !== MEDIA_TYPE.AUDIO) {
VideoLayout.updateVideoMutedForNoTracks(action.track.jitsiTrack.getParticipantId());
}
break;
}
return result;
});