Pārlūkot izejas kodu

Adjusts recording button handling to the new focus(not finished).

master
paweldomas 11 gadus atpakaļ
vecāks
revīzija
0f6b6ae960
2 mainītis faili ar 31 papildinājumiem un 8 dzēšanām
  1. 22
    5
      recording.js
  2. 9
    3
      toolbar.js

+ 22
- 5
recording.js Parādīt failu

1
 /* global $, $iq, config, connection, focusJid, messageHandler, Moderator,
1
 /* global $, $iq, config, connection, focusJid, messageHandler, Moderator,
2
    Toolbar, Util */
2
    Toolbar, Util */
3
 var Recording = (function (my) {
3
 var Recording = (function (my) {
4
-    var status = false;
5
     var recordingToken = null;
4
     var recordingToken = null;
6
-    var recordingEnabled = false;
5
+    var recordingEnabled;
7
 
6
 
8
     my.setRecordingToken = function (token) {
7
     my.setRecordingToken = function (token) {
9
         recordingToken = token;
8
         recordingToken = token;
71
         }
70
         }
72
 
71
 
73
         var oldState = recordingEnabled;
72
         var oldState = recordingEnabled;
74
-        Toolbar.toggleRecordingButtonState();
73
+        Toolbar.setRecordingButtonState(!oldState);
75
         my.setRecording(!oldState,
74
         my.setRecording(!oldState,
76
             recordingToken,
75
             recordingToken,
77
             function (state) {
76
             function (state) {
78
                 console.log("New recording state: ", state);
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
                     // Failed to change, reset the token because it might
97
                     // Failed to change, reset the token because it might
82
                     // have been wrong
98
                     // have been wrong
83
-                    Toolbar.toggleRecordingButtonState();
84
                     my.setRecordingToken(null);
99
                     my.setRecordingToken(null);
85
                 }
100
                 }
101
+                // Update with returned status
102
+                Toolbar.setRecordingButtonState(state);
86
             }
103
             }
87
         );
104
         );
88
     };
105
     };

+ 9
- 3
toolbar.js Parādīt failu

235
         }
235
         }
236
     };
236
     };
237
 
237
 
238
-    // Toggle the state of the recording button
239
-    my.toggleRecordingButtonState = function () {
240
-        $('#recordButton').toggleClass('active');
238
+    // Sets the state of the recording button
239
+    my.setRecordingButtonState = function (isRecording) {
240
+        if (isRecording) {
241
+            $('#recordButton').removeClass("icon-recEnable");
242
+            $('#recordButton').addClass("icon-recEnable active");
243
+        } else {
244
+            $('#recordButton').removeClass("icon-recEnable active");
245
+            $('#recordButton').addClass("icon-recEnable");
246
+        }
241
     };
247
     };
242
 
248
 
243
     // Shows or hides SIP calls button
249
     // Shows or hides SIP calls button

Notiek ielāde…
Atcelt
Saglabāt