|
@@ -4,6 +4,8 @@ import AudioMuteButton from './AudioMuteButton';
|
4
|
4
|
import HangupButton from './HangupButton';
|
5
|
5
|
import VideoMuteButton from './VideoMuteButton';
|
6
|
6
|
|
|
7
|
+const { api } = window.alwaysOnTop;
|
|
8
|
+
|
7
|
9
|
/**
|
8
|
10
|
* The type of the React {@code Component} props of {@link Toolbar}.
|
9
|
11
|
*/
|
|
@@ -25,12 +27,89 @@ interface IProps {
|
25
|
27
|
onMouseOver: (e?: React.MouseEvent) => void;
|
26
|
28
|
}
|
27
|
29
|
|
|
30
|
+/**
|
|
31
|
+ * The type of the React {@code Component} state of {@link Toolbar}.
|
|
32
|
+ */
|
|
33
|
+interface IState {
|
|
34
|
+
|
|
35
|
+ /**
|
|
36
|
+ * Whether audio button to be shown or not.
|
|
37
|
+ */
|
|
38
|
+ showAudioButton: boolean;
|
|
39
|
+
|
|
40
|
+ /**
|
|
41
|
+ * Whether video button to be shown or not.
|
|
42
|
+ */
|
|
43
|
+ showVideoButton: boolean;
|
|
44
|
+}
|
|
45
|
+
|
|
46
|
+type Props = Partial<IProps>;
|
|
47
|
+
|
28
|
48
|
/**
|
29
|
49
|
* Represents the toolbar in the Always On Top window.
|
30
|
50
|
*
|
31
|
51
|
* @augments Component
|
32
|
52
|
*/
|
33
|
|
-export default class Toolbar extends Component<IProps> {
|
|
53
|
+export default class Toolbar extends Component<Props, IState> {
|
|
54
|
+ /**
|
|
55
|
+ * Initializes a new {@code Toolbar} instance.
|
|
56
|
+ *
|
|
57
|
+ * @param {IProps} props - The React {@code Component} props to initialize the new {@code Toolbar} instance with.
|
|
58
|
+ */
|
|
59
|
+ constructor(props: Props) {
|
|
60
|
+ super(props);
|
|
61
|
+
|
|
62
|
+ this.state = {
|
|
63
|
+ showAudioButton: true,
|
|
64
|
+ showVideoButton: true
|
|
65
|
+ };
|
|
66
|
+
|
|
67
|
+ this._videoConferenceJoinedListener = this._videoConferenceJoinedListener.bind(this);
|
|
68
|
+ }
|
|
69
|
+
|
|
70
|
+ /**
|
|
71
|
+ * Sets listens for changing meetings while showing the toolbar.
|
|
72
|
+ *
|
|
73
|
+ * @inheritdoc
|
|
74
|
+ * @returns {void}
|
|
75
|
+ */
|
|
76
|
+ componentDidMount() {
|
|
77
|
+ api.on('videoConferenceJoined', this._videoConferenceJoinedListener);
|
|
78
|
+
|
|
79
|
+ this._videoConferenceJoinedListener();
|
|
80
|
+ }
|
|
81
|
+
|
|
82
|
+ /**
|
|
83
|
+ * Handles is visitor changes.
|
|
84
|
+ *
|
|
85
|
+ * @returns {void}
|
|
86
|
+ */
|
|
87
|
+ _videoConferenceJoinedListener() {
|
|
88
|
+ // for electron clients that embed the api and are not updated
|
|
89
|
+ if (!api.isVisitor) {
|
|
90
|
+ console.warn('external API not updated');
|
|
91
|
+
|
|
92
|
+ return;
|
|
93
|
+ }
|
|
94
|
+
|
|
95
|
+ const isNotVisitor = !api.isVisitor();
|
|
96
|
+
|
|
97
|
+ this.setState({
|
|
98
|
+ showAudioButton: isNotVisitor,
|
|
99
|
+ showVideoButton: isNotVisitor
|
|
100
|
+ });
|
|
101
|
+ }
|
|
102
|
+
|
|
103
|
+ /**
|
|
104
|
+ * Removes all listeners.
|
|
105
|
+ *
|
|
106
|
+ * @inheritdoc
|
|
107
|
+ * @returns {void}
|
|
108
|
+ */
|
|
109
|
+ componentWillUnmount() {
|
|
110
|
+ api.removeListener('videoConferenceJoined', this._videoConferenceJoinedListener);
|
|
111
|
+ }
|
|
112
|
+
|
34
|
113
|
/**
|
35
|
114
|
* Implements React's {@link Component#render()}.
|
36
|
115
|
*
|
|
@@ -49,8 +128,8 @@ export default class Toolbar extends Component<IProps> {
|
49
|
128
|
className = { `toolbox-content-items always-on-top-toolbox ${className}` }
|
50
|
129
|
onMouseOut = { onMouseOut }
|
51
|
130
|
onMouseOver = { onMouseOver }>
|
52
|
|
- <AudioMuteButton />
|
53
|
|
- <VideoMuteButton />
|
|
131
|
+ { this.state.showAudioButton && <AudioMuteButton /> }
|
|
132
|
+ { this.state.showVideoButton && <VideoMuteButton /> }
|
54
|
133
|
<HangupButton customClass = 'hangup-button' />
|
55
|
134
|
</div>
|
56
|
135
|
);
|