use JitsiParticipant to handle user roles
This commit is contained in:
parent
0460e7da29
commit
fbcd2d2320
29
app.js
29
app.js
|
@ -161,12 +161,10 @@ function initConference(localTracks, connection) {
|
|||
disableAudioLevels: config.disableAudioLevels
|
||||
});
|
||||
|
||||
var users = {};
|
||||
|
||||
APP.conference.localId = room.myUserId();
|
||||
Object.defineProperty(APP.conference, "membersCount", {
|
||||
get: function () {
|
||||
return Object.keys(users).length; // FIXME maybe +1?
|
||||
return room.getParticipants().length; // FIXME maybe +1?
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -175,9 +173,9 @@ function initConference(localTracks, connection) {
|
|||
return APP.settings.getDisplayName();
|
||||
}
|
||||
|
||||
var user = users[id];
|
||||
if (user && user.displayName) {
|
||||
return user.displayName;
|
||||
var participant = room.getParticipantById(id);
|
||||
if (participant && participant.getDisplayName()) {
|
||||
return participant.getDisplayName();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -191,19 +189,28 @@ function initConference(localTracks, connection) {
|
|||
|
||||
|
||||
room.on(ConferenceEvents.USER_JOINED, function (id) {
|
||||
users[id] = {
|
||||
displayName: undefined,
|
||||
tracks: []
|
||||
};
|
||||
// FIXME email???
|
||||
APP.UI.addUser(id);
|
||||
});
|
||||
room.on(ConferenceEvents.USER_LEFT, function (id) {
|
||||
delete users[id];
|
||||
APP.UI.removeUser(id);
|
||||
});
|
||||
|
||||
|
||||
room.on(ConferenceEvents.USER_ROLE_CHANGED, function (id, role) {
|
||||
if (APP.conference.isLocalId(id)) {
|
||||
console.info(`My role changed, new role: ${role}`);
|
||||
APP.conference.isModerator = room.isModerator();
|
||||
APP.UI.updateLocalRole(room.isModerator());
|
||||
} else {
|
||||
var user = room.getParticipantById(id);
|
||||
if (user) {
|
||||
APP.UI.updateUserRole(user);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
room.on(ConferenceEvents.TRACK_MUTE_CHANGED, function (track) {
|
||||
// FIXME handle mute
|
||||
});
|
||||
|
|
2371
lib-jitsi-meet.js
2371
lib-jitsi-meet.js
File diff suppressed because it is too large
Load Diff
|
@ -308,31 +308,6 @@ function initEtherpad(name) {
|
|||
Etherpad.init(name);
|
||||
}
|
||||
|
||||
function onLocalRoleChanged(jid, info, pres, isModerator) {
|
||||
console.info("My role changed, new role: " + info.role);
|
||||
onModeratorStatusChanged(isModerator);
|
||||
VideoLayout.showModeratorIndicator();
|
||||
SettingsMenu.onRoleChanged();
|
||||
|
||||
if (isModerator) {
|
||||
Authentication.closeAuthenticationWindow();
|
||||
messageHandler.notify(null, "notify.me",
|
||||
'connected', "notify.moderator");
|
||||
|
||||
Toolbar.checkAutoRecord();
|
||||
}
|
||||
}
|
||||
|
||||
function onModeratorStatusChanged(isModerator) {
|
||||
Toolbar.showSipCallButton(isModerator);
|
||||
Toolbar.showRecordingButton(
|
||||
isModerator); //&&
|
||||
// FIXME:
|
||||
// Recording visible if
|
||||
// there are at least 2(+ 1 focus) participants
|
||||
//Object.keys(connection.emuc.members).length >= 3);
|
||||
}
|
||||
|
||||
UI.notifyPasswordRequired = function (callback) {
|
||||
// password is required
|
||||
Toolbar.lockLockButton();
|
||||
|
@ -413,24 +388,43 @@ function onPeerVideoTypeChanged(resourceJid, newVideoType) {
|
|||
VideoLayout.onVideoTypeChanged(resourceJid, newVideoType);
|
||||
}
|
||||
|
||||
function onMucRoleChanged(role, displayName) {
|
||||
UI.updateLocalRole = function (isModerator) {
|
||||
VideoLayout.showModeratorIndicator();
|
||||
|
||||
if (role === 'moderator') {
|
||||
var messageKey, messageOptions = {};
|
||||
if (!displayName) {
|
||||
messageKey = "notify.grantedToUnknown";
|
||||
}
|
||||
else {
|
||||
messageKey = "notify.grantedTo";
|
||||
messageOptions = {to: displayName};
|
||||
}
|
||||
messageHandler.notify(
|
||||
displayName,'notify.somebody',
|
||||
'connected', messageKey,
|
||||
messageOptions);
|
||||
Toolbar.showSipCallButton(isModerator);
|
||||
Toolbar.showRecordingButton(isModerator);
|
||||
SettingsMenu.onRoleChanged();
|
||||
|
||||
if (isModerator) {
|
||||
Authentication.closeAuthenticationWindow();
|
||||
messageHandler.notify(null, "notify.me", 'connected', "notify.moderator");
|
||||
|
||||
Toolbar.checkAutoRecord();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
UI.updateUserRole = function (user) {
|
||||
VideoLayout.showModeratorIndicator();
|
||||
|
||||
if (!user.isModerator()) {
|
||||
return;
|
||||
}
|
||||
|
||||
var displayName = user.getDisplayName();
|
||||
if (displayName) {
|
||||
messageHandler.notify(
|
||||
displayName, 'notify.somebody',
|
||||
'connected', 'notify.grantedTo', {
|
||||
to: displayName
|
||||
}
|
||||
);
|
||||
} else {
|
||||
messageHandler.notify(
|
||||
'', 'notify.somebody',
|
||||
'connected', 'notify.grantedToUnknown', {}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
UI.notifyAuthRequired = function (intervalCallback) {
|
||||
Authentication.openAuthenticationDialog(
|
||||
|
|
Loading…
Reference in New Issue