From 600c98457696bfcc733144a50e4921823e842928 Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 6 Dec 2018 13:59:56 +0100 Subject: [PATCH] Only show the user colors in the userlist if the app supports it --- www/common/sframe-app-framework.js | 5 ++++- www/common/toolbar3.js | 16 ++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/www/common/sframe-app-framework.js b/www/common/sframe-app-framework.js index ee3feeffb..c16805b2b 100644 --- a/www/common/sframe-app-framework.js +++ b/www/common/sframe-app-framework.js @@ -647,7 +647,10 @@ define([ setContentGetter: function (cg) { contentGetter = cg; }, // Set the function providing the cursor position when request by the framework. - setCursorGetter: function (cg) { cursorGetter = cg; }, + setCursorGetter: function (cg) { + toolbar.showColors(); + cursorGetter = cg; + }, onCursorUpdate: evCursorUpdate.reg, updateCursor: function () { if (cursor && cursorGetter) { diff --git a/www/common/toolbar3.js b/www/common/toolbar3.js index 2a3085fb7..cfc51e7f0 100644 --- a/www/common/toolbar3.js +++ b/www/common/toolbar3.js @@ -5,10 +5,11 @@ define([ '/common/common-ui-elements.js', '/common/common-interface.js', '/common/common-hash.js', + '/common/common-util.js', '/common/common-feedback.js', '/contacts/messenger-ui.js', '/customize/messages.js', -], function ($, Config, ApiConfig, UIElements, UI, Hash, Feedback, +], function ($, Config, ApiConfig, UIElements, UI, Hash, Util, Feedback, MessengerUI, Messages) { var Common; @@ -161,6 +162,7 @@ MessengerUI, Messages) { } }); }; + var showColors = false; var updateUserList = function (toolbar, config) { // Make sure the elements are displayed var $userButtons = toolbar.userlist; @@ -231,7 +233,7 @@ MessengerUI, Messages) { editUsersNames.forEach(function (data) { var name = data.name || Messages.anonymous; var $span = $('', {'class': 'cp-avatar'}); - if (data.color) { + if (data.color && showColors) { $span.css('border-color', data.color); } var $rightCol = $('', {'class': 'cp-toolbar-userlist-rightcol'}); @@ -1169,6 +1171,16 @@ MessengerUI, Messages) { } }; + // Show user colors in the userlist only if the app is compatible and if the user + // wants to see the cursors + toolbar.showColors = function () { + if (!config.metadataMgr) { return; } + var privateData = config.metadataMgr.getPrivateData(); + var show = Util.find(privateData, ['settings', 'general', 'cursor', 'show']); + if (show === false) { return; } + showColors = true; + }; + // On log out, remove permanently the realtime elements of the toolbar Common.onLogout(function () { failed();