Bläddra i källkod

use JitsiParticipant to handle user roles

j8
isymchych 9 år sedan
förälder
incheckning
fbcd2d2320
3 ändrade filer med 1713 tillägg och 1131 borttagningar
  1. 18
    11
      app.js
  2. 1662
    1081
      lib-jitsi-meet.js
  3. 33
    39
      modules/UI/UI.js

+ 18
- 11
app.js Visa fil

161
         disableAudioLevels: config.disableAudioLevels
161
         disableAudioLevels: config.disableAudioLevels
162
     });
162
     });
163
 
163
 
164
-    var users = {};
165
-
166
     APP.conference.localId = room.myUserId();
164
     APP.conference.localId = room.myUserId();
167
     Object.defineProperty(APP.conference, "membersCount", {
165
     Object.defineProperty(APP.conference, "membersCount", {
168
         get: function () {
166
         get: function () {
169
-            return Object.keys(users).length; // FIXME maybe +1?
167
+            return room.getParticipants().length; // FIXME maybe +1?
170
         }
168
         }
171
     });
169
     });
172
 
170
 
175
             return APP.settings.getDisplayName();
173
             return APP.settings.getDisplayName();
176
         }
174
         }
177
 
175
 
178
-        var user = users[id];
179
-        if (user && user.displayName) {
180
-            return user.displayName;
176
+        var participant = room.getParticipantById(id);
177
+        if (participant && participant.getDisplayName()) {
178
+            return participant.getDisplayName();
181
         }
179
         }
182
     }
180
     }
183
 
181
 
191
 
189
 
192
 
190
 
193
     room.on(ConferenceEvents.USER_JOINED, function (id) {
191
     room.on(ConferenceEvents.USER_JOINED, function (id) {
194
-        users[id] = {
195
-            displayName: undefined,
196
-            tracks: []
197
-        };
198
         // FIXME email???
192
         // FIXME email???
199
         APP.UI.addUser(id);
193
         APP.UI.addUser(id);
200
     });
194
     });
201
     room.on(ConferenceEvents.USER_LEFT, function (id) {
195
     room.on(ConferenceEvents.USER_LEFT, function (id) {
202
-        delete users[id];
203
         APP.UI.removeUser(id);
196
         APP.UI.removeUser(id);
204
     });
197
     });
205
 
198
 
206
 
199
 
200
+    room.on(ConferenceEvents.USER_ROLE_CHANGED, function (id, role) {
201
+        if (APP.conference.isLocalId(id)) {
202
+            console.info(`My role changed, new role: ${role}`);
203
+            APP.conference.isModerator = room.isModerator();
204
+            APP.UI.updateLocalRole(room.isModerator());
205
+        } else {
206
+            var user = room.getParticipantById(id);
207
+            if (user) {
208
+                APP.UI.updateUserRole(user);
209
+            }
210
+        }
211
+    });
212
+
213
+
207
     room.on(ConferenceEvents.TRACK_MUTE_CHANGED, function (track) {
214
     room.on(ConferenceEvents.TRACK_MUTE_CHANGED, function (track) {
208
         // FIXME handle mute
215
         // FIXME handle mute
209
     });
216
     });

+ 1662
- 1081
lib-jitsi-meet.js
Filskillnaden har hållits tillbaka eftersom den är för stor
Visa fil


+ 33
- 39
modules/UI/UI.js Visa fil

308
     Etherpad.init(name);
308
     Etherpad.init(name);
309
 }
309
 }
310
 
310
 
311
-function onLocalRoleChanged(jid, info, pres, isModerator) {
312
-    console.info("My role changed, new role: " + info.role);
313
-    onModeratorStatusChanged(isModerator);
314
-    VideoLayout.showModeratorIndicator();
315
-    SettingsMenu.onRoleChanged();
316
-
317
-    if (isModerator) {
318
-        Authentication.closeAuthenticationWindow();
319
-        messageHandler.notify(null, "notify.me",
320
-            'connected', "notify.moderator");
321
-
322
-        Toolbar.checkAutoRecord();
323
-    }
324
-}
325
-
326
-function onModeratorStatusChanged(isModerator) {
327
-    Toolbar.showSipCallButton(isModerator);
328
-    Toolbar.showRecordingButton(
329
-        isModerator); //&&
330
-    // FIXME:
331
-    // Recording visible if
332
-    // there are at least 2(+ 1 focus) participants
333
-    //Object.keys(connection.emuc.members).length >= 3);
334
-}
335
-
336
 UI.notifyPasswordRequired = function (callback) {
311
 UI.notifyPasswordRequired = function (callback) {
337
     // password is required
312
     // password is required
338
     Toolbar.lockLockButton();
313
     Toolbar.lockLockButton();
413
     VideoLayout.onVideoTypeChanged(resourceJid, newVideoType);
388
     VideoLayout.onVideoTypeChanged(resourceJid, newVideoType);
414
 }
389
 }
415
 
390
 
416
-function onMucRoleChanged(role, displayName) {
391
+UI.updateLocalRole = function (isModerator) {
417
     VideoLayout.showModeratorIndicator();
392
     VideoLayout.showModeratorIndicator();
418
 
393
 
419
-    if (role === 'moderator') {
420
-        var messageKey, messageOptions = {};
421
-        if (!displayName) {
422
-            messageKey = "notify.grantedToUnknown";
423
-        }
424
-        else {
425
-            messageKey = "notify.grantedTo";
426
-            messageOptions = {to: displayName};
427
-        }
394
+    Toolbar.showSipCallButton(isModerator);
395
+    Toolbar.showRecordingButton(isModerator);
396
+    SettingsMenu.onRoleChanged();
397
+
398
+    if (isModerator) {
399
+        Authentication.closeAuthenticationWindow();
400
+        messageHandler.notify(null, "notify.me", 'connected', "notify.moderator");
401
+
402
+        Toolbar.checkAutoRecord();
403
+    }
404
+};
405
+
406
+UI.updateUserRole = function (user) {
407
+    VideoLayout.showModeratorIndicator();
408
+
409
+    if (!user.isModerator()) {
410
+        return;
411
+    }
412
+
413
+    var displayName = user.getDisplayName();
414
+    if (displayName) {
428
         messageHandler.notify(
415
         messageHandler.notify(
429
-            displayName,'notify.somebody',
430
-            'connected', messageKey,
431
-            messageOptions);
416
+            displayName, 'notify.somebody',
417
+            'connected', 'notify.grantedTo', {
418
+                to: displayName
419
+            }
420
+        );
421
+    } else {
422
+        messageHandler.notify(
423
+            '', 'notify.somebody',
424
+            'connected', 'notify.grantedToUnknown', {}
425
+        );
432
     }
426
     }
433
-}
427
+};
434
 
428
 
435
 UI.notifyAuthRequired = function (intervalCallback) {
429
 UI.notifyAuthRequired = function (intervalCallback) {
436
     Authentication.openAuthenticationDialog(
430
     Authentication.openAuthenticationDialog(

Laddar…
Avbryt
Spara