|
@@ -1,9 +1,8 @@
|
1
|
1
|
/* global $, $iq, config, connection, focusJid, messageHandler, Moderator,
|
2
|
2
|
Toolbar, Util */
|
3
|
3
|
var Recording = (function (my) {
|
4
|
|
- var status = false;
|
5
|
4
|
var recordingToken = null;
|
6
|
|
- var recordingEnabled = false;
|
|
5
|
+ var recordingEnabled;
|
7
|
6
|
|
8
|
7
|
my.setRecordingToken = function (token) {
|
9
|
8
|
recordingToken = token;
|
|
@@ -71,18 +70,36 @@ var Recording = (function (my) {
|
71
|
70
|
}
|
72
|
71
|
|
73
|
72
|
var oldState = recordingEnabled;
|
74
|
|
- Toolbar.toggleRecordingButtonState();
|
|
73
|
+ Toolbar.setRecordingButtonState(!oldState);
|
75
|
74
|
my.setRecording(!oldState,
|
76
|
75
|
recordingToken,
|
77
|
76
|
function (state) {
|
78
|
77
|
console.log("New recording state: ", state);
|
79
|
|
- if (state == oldState)
|
|
78
|
+ if (state === oldState)
|
80
|
79
|
{
|
|
80
|
+ // FIXME: new focus:
|
|
81
|
+ // this will not work when moderator changes
|
|
82
|
+ // during active session. Then it will assume that
|
|
83
|
+ // recording status has changed to true, but it might have
|
|
84
|
+ // been already true(and we only received actual status from
|
|
85
|
+ // the focus).
|
|
86
|
+ //
|
|
87
|
+ // SO we start with status null, so that it is initialized
|
|
88
|
+ // here and will fail only after second click, so if invalid
|
|
89
|
+ // token was used we have to press the button twice before
|
|
90
|
+ // current status will be fetched and token will be reset.
|
|
91
|
+ //
|
|
92
|
+ // Reliable way would be to return authentication error.
|
|
93
|
+ // Or status update when moderator connects.
|
|
94
|
+ // Or we have to stop recording session when current
|
|
95
|
+ // moderator leaves the room.
|
|
96
|
+
|
81
|
97
|
// Failed to change, reset the token because it might
|
82
|
98
|
// have been wrong
|
83
|
|
- Toolbar.toggleRecordingButtonState();
|
84
|
99
|
my.setRecordingToken(null);
|
85
|
100
|
}
|
|
101
|
+ // Update with returned status
|
|
102
|
+ Toolbar.setRecordingButtonState(state);
|
86
|
103
|
}
|
87
|
104
|
);
|
88
|
105
|
};
|