mirror of https://github.com/jitsi/jitsi-meet
Singleton follow me (#4144)
* Prints errors in case of wrong initialization. Not printing can masks some errors in the code. * Allow only one Follow Me moderator in a meeting. * Sends Follow Me state with all presences of the moderator. This fixes an issue where the moderator sends the Follow Me state and then for example mute or unmute video (this will produce a presence without Follow Me state) and the new comers will not reflect current Follow Me state till a change of it comes. * Changes fixing comments. * Changes fixing comments.pull/4147/head jitsi-meet_3702
parent
98c8fb09c4
commit
a6555c5d24
@ -0,0 +1,23 @@ |
||||
// @flow
|
||||
|
||||
/** |
||||
* The id of the Follow Me moderator. |
||||
* |
||||
* { |
||||
* type: SET_FOLLOW_ME_MODERATOR, |
||||
* id: boolean |
||||
* } |
||||
*/ |
||||
export const SET_FOLLOW_ME_MODERATOR = 'SET_FOLLOW_ME_MODERATOR'; |
||||
|
||||
/** |
||||
* The type of (redux) action which updates the current known state of the |
||||
* Follow Me feature. |
||||
* |
||||
* |
||||
* { |
||||
* type: SET_FOLLOW_ME_STATE, |
||||
* state: boolean |
||||
* } |
||||
*/ |
||||
export const SET_FOLLOW_ME_STATE = 'SET_FOLLOW_ME_STATE'; |
@ -0,0 +1,38 @@ |
||||
// @flow
|
||||
|
||||
import { |
||||
SET_FOLLOW_ME_MODERATOR, |
||||
SET_FOLLOW_ME_STATE |
||||
} from './actionTypes'; |
||||
|
||||
/** |
||||
* Sets the current moderator id or clears it. |
||||
* |
||||
* @param {?string} id - The Follow Me moderator participant id. |
||||
* @returns {{ |
||||
* type: SET_FOLLOW_ME_MODERATOR, |
||||
* id, string |
||||
* }} |
||||
*/ |
||||
export function setFollowMeModerator(id: ?string) { |
||||
return { |
||||
type: SET_FOLLOW_ME_MODERATOR, |
||||
id |
||||
}; |
||||
} |
||||
|
||||
/** |
||||
* Sets the Follow Me feature state. |
||||
* |
||||
* @param {?Object} state - The current state. |
||||
* @returns {{ |
||||
* type: SET_FOLLOW_ME_STATE, |
||||
* state: Object |
||||
* }} |
||||
*/ |
||||
export function setFollowMeState(state: ?Object) { |
||||
return { |
||||
type: SET_FOLLOW_ME_STATE, |
||||
state |
||||
}; |
||||
} |
@ -1,2 +1,4 @@ |
||||
export * from './middleware'; |
||||
export * from './subscriber'; |
||||
|
||||
import './reducer'; |
||||
|
@ -0,0 +1,33 @@ |
||||
// @flow
|
||||
|
||||
import { |
||||
SET_FOLLOW_ME_MODERATOR, |
||||
SET_FOLLOW_ME_STATE |
||||
} from './actionTypes'; |
||||
import { ReducerRegistry, set } from '../base/redux'; |
||||
|
||||
/** |
||||
* Listen for actions that contain the Follow Me feature active state, so that it can be stored. |
||||
*/ |
||||
ReducerRegistry.register( |
||||
'features/follow-me', |
||||
(state = {}, action) => { |
||||
switch (action.type) { |
||||
|
||||
case SET_FOLLOW_ME_MODERATOR: { |
||||
let newState = set(state, 'moderator', action.id); |
||||
|
||||
if (!action.id) { |
||||
// clear the state if feature becomes disabled
|
||||
newState = set(newState, 'state', undefined); |
||||
} |
||||
|
||||
return newState; |
||||
} |
||||
case SET_FOLLOW_ME_STATE: { |
||||
return set(state, 'state', action.state); |
||||
} |
||||
} |
||||
|
||||
return state; |
||||
}); |
Loading…
Reference in new issue