forked from jitsi/jitsi-meet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
00b41db
commit 240b033
Showing
22 changed files
with
188 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,100 @@ | ||
import { | ||
PIN_PARTICIPANT, | ||
getPinnedParticipant, | ||
pinParticipant | ||
} from '../base/participants'; | ||
import { MiddlewareRegistry } from '../base/redux'; | ||
import { SET_DOCUMENT_EDITING_STATUS, toggleDocument } from '../etherpad'; | ||
// @flow | ||
|
||
import { getCurrentConference } from '../base/conference'; | ||
import { PIN_PARTICIPANT, pinParticipant, getPinnedParticipant } from '../base/participants'; | ||
import { MiddlewareRegistry, StateListenerRegistry } from '../base/redux'; | ||
import { SET_DOCUMENT_EDITING_STATUS } from '../etherpad'; | ||
|
||
import { SET_TILE_VIEW } from './actionTypes'; | ||
import { setTileView } from './actions'; | ||
|
||
import './subscriber'; | ||
|
||
let previousTileViewEnabled; | ||
|
||
/** | ||
* Middleware which intercepts actions and updates tile view related state. | ||
* | ||
* @param {Store} store - The redux store. | ||
* @returns {Function} | ||
*/ | ||
MiddlewareRegistry.register(store => next => action => { | ||
const result = next(action); | ||
|
||
switch (action.type) { | ||
|
||
// Actions that temporarily clear the user preferred state of tile view, | ||
// then re-set it when needed. | ||
case PIN_PARTICIPANT: { | ||
const isPinning = Boolean(action.participant.id); | ||
const { tileViewEnabled } = store.getState()['features/video-layout']; | ||
const pinnedParticipant = getPinnedParticipant(store.getState()); | ||
|
||
if (isPinning && tileViewEnabled) { | ||
store.dispatch(setTileView(false)); | ||
if (pinnedParticipant) { | ||
_storeTileViewStateAndClear(store); | ||
} else { | ||
_restoreTileViewState(store); | ||
} | ||
|
||
break; | ||
} | ||
|
||
case SET_DOCUMENT_EDITING_STATUS: | ||
if (action.editing) { | ||
store.dispatch(setTileView(false)); | ||
_storeTileViewStateAndClear(store); | ||
} else { | ||
_restoreTileViewState(store); | ||
} | ||
|
||
break; | ||
|
||
case SET_TILE_VIEW: { | ||
const state = store.getState(); | ||
// Things to update when tile view state changes | ||
case SET_TILE_VIEW: | ||
if (action.enabled && getPinnedParticipant(store)) { | ||
store.dispatch(pinParticipant(null)); | ||
} | ||
} | ||
|
||
|
||
if (action.enabled) { | ||
if (getPinnedParticipant(state)) { | ||
store.dispatch(pinParticipant(null)); | ||
} | ||
return result; | ||
}); | ||
|
||
if (state['features/etherpad'].editing) { | ||
store.dispatch(toggleDocument()); | ||
} | ||
/** | ||
* Set up state change listener to perform maintenance tasks when the conference | ||
* is left or failed. | ||
*/ | ||
StateListenerRegistry.register( | ||
state => getCurrentConference(state), | ||
(conference, { dispatch }, previousConference) => { | ||
if (conference !== previousConference) { | ||
// conference changed, left or failed... | ||
// Clear tile view state. | ||
dispatch(setTileView()); | ||
} | ||
}); | ||
|
||
break; | ||
} | ||
/** | ||
* Respores tile view state, if it wasn't updated since then. | ||
* | ||
* @param {Object} store - The Redux Store. | ||
* @returns {void} | ||
*/ | ||
function _restoreTileViewState({ dispatch, getState }) { | ||
const { tileViewEnabled } = getState()['features/video-layout']; | ||
|
||
if (tileViewEnabled === undefined && previousTileViewEnabled !== undefined) { | ||
dispatch(setTileView(previousTileViewEnabled)); | ||
} | ||
|
||
return next(action); | ||
}); | ||
previousTileViewEnabled = undefined; | ||
} | ||
|
||
/** | ||
* Stores the current tile view state and clears it. | ||
* | ||
* @param {Object} store - The Redux Store. | ||
* @returns {void} | ||
*/ | ||
function _storeTileViewStateAndClear({ dispatch, getState }) { | ||
const { tileViewEnabled } = getState()['features/video-layout']; | ||
|
||
if (tileViewEnabled !== undefined) { | ||
previousTileViewEnabled = tileViewEnabled; | ||
dispatch(setTileView(undefined)); | ||
} | ||
} |
Oops, something went wrong.