瀏覽代碼

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

j8
paweldomas 10 年之前
父節點
當前提交
0f6b6ae960
共有 2 個檔案被更改,包括 31 行新增8 行删除
  1. 22
    5
      recording.js
  2. 9
    3
      toolbar.js

+ 22
- 5
recording.js 查看文件

@@ -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
     };

+ 9
- 3
toolbar.js 查看文件

@@ -235,9 +235,15 @@ var Toolbar = (function (my) {
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 249
     // Shows or hides SIP calls button

Loading…
取消
儲存