Fix -1 viewer in the userlist when disconnected

pull/1/head
yflory 7 years ago
parent cf3024ef5b
commit 1871749b6f

@ -57,6 +57,7 @@ define(function () {
out.viewers = "lecteurs"; out.viewers = "lecteurs";
out.editor = "éditeur"; out.editor = "éditeur";
out.editors = "éditeurs"; out.editors = "éditeurs";
out.userlist_offline = "Vous êtes actuellement hors-ligne, la liste des utilisateurs n'est pas disponible.";
out.language = "Langue"; out.language = "Langue";

@ -59,6 +59,7 @@ define(function () {
out.viewers = "viewers"; out.viewers = "viewers";
out.editor = "editor"; out.editor = "editor";
out.editors = "editors"; out.editors = "editors";
out.userlist_offline = "You're currently offline, the user list is not available.";
out.language = "Language"; out.language = "Language";

@ -154,6 +154,7 @@ define([
var $userlistContent = toolbar.userlistContent; var $userlistContent = toolbar.userlistContent;
var metadataMgr = config.metadataMgr; var metadataMgr = config.metadataMgr;
var online = metadataMgr.isConnected();
var userData = metadataMgr.getMetadata().users; var userData = metadataMgr.getMetadata().users;
var viewers = metadataMgr.getViewers(); var viewers = metadataMgr.getViewers();
var priv = metadataMgr.getPrivateData(); var priv = metadataMgr.getPrivateData();
@ -184,7 +185,23 @@ define([
// Update the userlist // Update the userlist
var $editUsers = $userlistContent.find('.' + USERLIST_CLS).html(''); var $editUsers = $userlistContent.find('.' + USERLIST_CLS).html('');
var $editUsersList = $('<div>', {'class': 'cp-toolbar-userlist-others'}); var $editUsersList = $('<div>', {'class': 'cp-toolbar-userlist-others'})
.appendTo($editUsers);
if (!online) {
$('<em>').text(Messages.userlist_offline).appendTo($editUsersList);
numberOfEditUsers = '?';
numberOfViewUsers = '?';
};
// Update the buttons
var fa_editusers = '<span class="fa fa-users"></span>';
var fa_viewusers = '<span class="fa fa-eye"></span>';
var $spansmall = $('<span>').html(fa_editusers + ' ' + numberOfEditUsers + '&nbsp;&nbsp; ' + fa_viewusers + ' ' + numberOfViewUsers);
$userButtons.find('.cp-dropdown-button-title').html('').append($spansmall);
if (!online) { return; }
// Display the userlist
// Editors // Editors
var pendingFriends = Common.getPendingFriends(); var pendingFriends = Common.getPendingFriends();
@ -237,7 +254,6 @@ define([
$span.data('uid', data.uid); $span.data('uid', data.uid);
$editUsersList.append($span); $editUsersList.append($span);
}); });
$editUsers.append($editUsersList);
// Viewers // Viewers
if (numberOfViewUsers > 0) { if (numberOfViewUsers > 0) {
@ -246,12 +262,6 @@ define([
viewText += numberOfViewUsers + ' ' + viewerText + '</div>'; viewText += numberOfViewUsers + ' ' + viewerText + '</div>';
$editUsers.append(viewText); $editUsers.append(viewText);
} }
// Update the buttons
var fa_editusers = '<span class="fa fa-users"></span>';
var fa_viewusers = '<span class="fa fa-eye"></span>';
var $spansmall = $('<span>').html(fa_editusers + ' ' + numberOfEditUsers + '&nbsp;&nbsp; ' + fa_viewusers + ' ' + numberOfViewUsers);
$userButtons.find('.cp-dropdown-button-title').html('').append($spansmall);
}; };
var initUserList = function (toolbar, config) { var initUserList = function (toolbar, config) {

Loading…
Cancel
Save