|
@@ -3,17 +3,19 @@
|
3
|
3
|
import { connect } from 'react-redux';
|
4
|
4
|
|
5
|
5
|
import { translate } from '../../base/i18n';
|
|
6
|
+import { isLocalParticipantModerator } from '../../base/participants';
|
6
|
7
|
import { AbstractButton } from '../../base/toolbox';
|
7
|
8
|
import type { AbstractButtonProps } from '../../base/toolbox';
|
8
|
9
|
|
9
|
|
-import { beginRoomLockRequest } from '../actions';
|
|
10
|
+import { beginRoomLockRequest, unlockRoom } from '../actions';
|
10
|
11
|
|
11
|
12
|
type Props = AbstractButtonProps & {
|
12
|
13
|
|
13
|
14
|
/**
|
14
|
|
- * The current conference.
|
|
15
|
+ * Whether the current local participant is a moderator, therefore is
|
|
16
|
+ * allowed to lock or unlock the conference.
|
15
|
17
|
*/
|
16
|
|
- _conference: Object,
|
|
18
|
+ _localParticipantModerator: boolean,
|
17
|
19
|
|
18
|
20
|
/**
|
19
|
21
|
* Whether the current conference is locked or not.
|
|
@@ -43,7 +45,13 @@ class RoomLockButton extends AbstractButton<Props, *> {
|
43
|
45
|
* @returns {void}
|
44
|
46
|
*/
|
45
|
47
|
_handleClick() {
|
46
|
|
- this.props.dispatch(beginRoomLockRequest());
|
|
48
|
+ const { dispatch, _locked } = this.props;
|
|
49
|
+
|
|
50
|
+ if (_locked) {
|
|
51
|
+ dispatch(unlockRoom());
|
|
52
|
+ } else {
|
|
53
|
+ dispatch(beginRoomLockRequest());
|
|
54
|
+ }
|
47
|
55
|
}
|
48
|
56
|
|
49
|
57
|
/**
|
|
@@ -54,7 +62,7 @@ class RoomLockButton extends AbstractButton<Props, *> {
|
54
|
62
|
* @returns {boolean}
|
55
|
63
|
*/
|
56
|
64
|
_isDisabled() {
|
57
|
|
- return !this.props._conference;
|
|
65
|
+ return !this.props._localParticipantModerator;
|
58
|
66
|
}
|
59
|
67
|
|
60
|
68
|
/**
|
|
@@ -76,14 +84,16 @@ class RoomLockButton extends AbstractButton<Props, *> {
|
76
|
84
|
* @param {Object} state - The Redux state.
|
77
|
85
|
* @private
|
78
|
86
|
* @returns {{
|
79
|
|
- * _audioOnly: boolean
|
|
87
|
+ * _localParticipantModerator: boolean,
|
|
88
|
+ * _locked: boolean
|
80
|
89
|
* }}
|
81
|
90
|
*/
|
82
|
91
|
function _mapStateToProps(state): Object {
|
83
|
92
|
const { conference, locked } = state['features/base/conference'];
|
84
|
93
|
|
85
|
94
|
return {
|
86
|
|
- _conference: conference,
|
|
95
|
+ _localParticipantModerator:
|
|
96
|
+ Boolean(conference && isLocalParticipantModerator(state)),
|
87
|
97
|
_locked: Boolean(conference && locked)
|
88
|
98
|
};
|
89
|
99
|
}
|