From 1871749b6f07ac35494c4fd0c304a566e0e99d73 Mon Sep 17 00:00:00 2001 From: yflory Date: Fri, 3 Nov 2017 15:14:23 +0100 Subject: [PATCH] Fix -1 viewer in the userlist when disconnected --- customize.dist/translations/messages.fr.js | 1 + customize.dist/translations/messages.js | 1 + www/common/toolbar3.js | 26 +++++++++++++++------- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/customize.dist/translations/messages.fr.js b/customize.dist/translations/messages.fr.js index fc7a98fe5..d2db0bc37 100644 --- a/customize.dist/translations/messages.fr.js +++ b/customize.dist/translations/messages.fr.js @@ -57,6 +57,7 @@ define(function () { out.viewers = "lecteurs"; out.editor = "éditeur"; out.editors = "éditeurs"; + out.userlist_offline = "Vous êtes actuellement hors-ligne, la liste des utilisateurs n'est pas disponible."; out.language = "Langue"; diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js index 734d493cf..c8ee82823 100644 --- a/customize.dist/translations/messages.js +++ b/customize.dist/translations/messages.js @@ -59,6 +59,7 @@ define(function () { out.viewers = "viewers"; out.editor = "editor"; out.editors = "editors"; + out.userlist_offline = "You're currently offline, the user list is not available."; out.language = "Language"; diff --git a/www/common/toolbar3.js b/www/common/toolbar3.js index bca41bd9b..4cb8011a4 100644 --- a/www/common/toolbar3.js +++ b/www/common/toolbar3.js @@ -154,6 +154,7 @@ define([ var $userlistContent = toolbar.userlistContent; var metadataMgr = config.metadataMgr; + var online = metadataMgr.isConnected(); var userData = metadataMgr.getMetadata().users; var viewers = metadataMgr.getViewers(); var priv = metadataMgr.getPrivateData(); @@ -184,7 +185,23 @@ define([ // Update the userlist var $editUsers = $userlistContent.find('.' + USERLIST_CLS).html(''); - var $editUsersList = $('
', {'class': 'cp-toolbar-userlist-others'}); + var $editUsersList = $('
', {'class': 'cp-toolbar-userlist-others'}) + .appendTo($editUsers); + + if (!online) { + $('').text(Messages.userlist_offline).appendTo($editUsersList); + numberOfEditUsers = '?'; + numberOfViewUsers = '?'; + }; + + // Update the buttons + var fa_editusers = ''; + var fa_viewusers = ''; + var $spansmall = $('').html(fa_editusers + ' ' + numberOfEditUsers + '   ' + fa_viewusers + ' ' + numberOfViewUsers); + $userButtons.find('.cp-dropdown-button-title').html('').append($spansmall); + + if (!online) { return; } + // Display the userlist // Editors var pendingFriends = Common.getPendingFriends(); @@ -237,7 +254,6 @@ define([ $span.data('uid', data.uid); $editUsersList.append($span); }); - $editUsers.append($editUsersList); // Viewers if (numberOfViewUsers > 0) { @@ -246,12 +262,6 @@ define([ viewText += numberOfViewUsers + ' ' + viewerText + '
'; $editUsers.append(viewText); } - - // Update the buttons - var fa_editusers = ''; - var fa_viewusers = ''; - var $spansmall = $('').html(fa_editusers + ' ' + numberOfEditUsers + '   ' + fa_viewusers + ' ' + numberOfViewUsers); - $userButtons.find('.cp-dropdown-button-title').html('').append($spansmall); }; var initUserList = function (toolbar, config) {