From 7ef142bb66685c0ddac2fe3ef6e544f7597f11b6 Mon Sep 17 00:00:00 2001 From: Karl Prieb Date: Tue, 14 Nov 2017 18:26:35 -0200 Subject: [PATCH] Add option to enable/disable message counter on sidebar --- packages/rocketchat-i18n/i18n/en.i18n.json | 2 ++ .../client/imports/components/sidebar/rooms-list.css | 1 + .../client/accountPreferences.html | 12 ++++++++++++ .../client/accountPreferences.js | 2 ++ packages/rocketchat-ui-sidenav/client/roomList.html | 12 +++++++----- packages/rocketchat-ui-sidenav/client/roomList.js | 5 +++++ server/methods/saveUserPreferences.js | 1 + 7 files changed, 30 insertions(+), 5 deletions(-) diff --git a/packages/rocketchat-i18n/i18n/en.i18n.json b/packages/rocketchat-i18n/i18n/en.i18n.json index 823a77f35cc5..4b8ec9064471 100644 --- a/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/packages/rocketchat-i18n/i18n/en.i18n.json @@ -1613,6 +1613,7 @@ "Should_be_a_URL_of_an_image": "Should be a URL of an image.", "Should_exists_a_user_with_this_username": "The user must already exist.", "Show_all": "Show All", + "Show_message_counter_on_sidebar": "Show message counter on sidebar", "Show_more": "Show more", "show_offline_users": "show offline users", "Show_on_registration_page": "Show on registration page", @@ -1623,6 +1624,7 @@ "Showing_archived_results": "

Showing %s archived results

", "Showing_online_users": "Showing: __total_showing__, Online: __online__, Total: __total__ users", "Showing_results": "

Showing %s results

", + "Sidebar": "Sidebar", "Sidebar_list_mode": "Sidebar Channel List Mode", "Sign_in_to_start_talking": "Sign in to start talking", "since_creation": "since %s", diff --git a/packages/rocketchat-theme/client/imports/components/sidebar/rooms-list.css b/packages/rocketchat-theme/client/imports/components/sidebar/rooms-list.css index f6860dcac7a3..71c2ae69af98 100644 --- a/packages/rocketchat-theme/client/imports/components/sidebar/rooms-list.css +++ b/packages/rocketchat-theme/client/imports/components/sidebar/rooms-list.css @@ -34,6 +34,7 @@ font-size: var(--rooms-list-title-text-size); align-items: center; + justify-content: space-between; &-text--livechat { flex: 1; diff --git a/packages/rocketchat-ui-account/client/accountPreferences.html b/packages/rocketchat-ui-account/client/accountPreferences.html index b9b827b28946..c14da639e9e6 100644 --- a/packages/rocketchat-ui-account/client/accountPreferences.html +++ b/packages/rocketchat-ui-account/client/accountPreferences.html @@ -201,6 +201,18 @@

{{_ "Messages"}}

+
+

{{_ "Sidebar"}}

+
+
+ +
+ + +
+
+
+

{{_ "Highlights"}}

diff --git a/packages/rocketchat-ui-account/client/accountPreferences.js b/packages/rocketchat-ui-account/client/accountPreferences.js index 30793a442276..24a91e43d861 100644 --- a/packages/rocketchat-ui-account/client/accountPreferences.js +++ b/packages/rocketchat-ui-account/client/accountPreferences.js @@ -164,6 +164,8 @@ Template.accountPreferences.onCreated(function() { data.unreadAlert = $('#unreadAlert').find('input:checked').val(); data.notificationsSoundVolume = parseInt($('#notificationsSoundVolume').val()); + data.messageCounterSidebar = $('#messageCounterSidebar').find('input:checked').val(); + Meteor.call('saveUserPreferences', data, function(error, results) { if (results) { toastr.success(t('Preferences_saved')); diff --git a/packages/rocketchat-ui-sidenav/client/roomList.html b/packages/rocketchat-ui-sidenav/client/roomList.html index 4b4ef3ea92d2..2975f9fe55dd 100644 --- a/packages/rocketchat-ui-sidenav/client/roomList.html +++ b/packages/rocketchat-ui-sidenav/client/roomList.html @@ -6,11 +6,13 @@ {{#if shouldAppear .. .}}

{{_ ../label}} - {{#with count}} - {{#if .}} - {{.}} - {{/if}} - {{/with}} + {{#if showCounter}} + {{#with count}} + {{#if .}} + {{.}} + {{/if}} + {{/with}} + {{/if}}

    {{#each room in this}} diff --git a/packages/rocketchat-ui-sidenav/client/roomList.js b/packages/rocketchat-ui-sidenav/client/roomList.js index 81929434b5be..e9cee2b79279 100644 --- a/packages/rocketchat-ui-sidenav/client/roomList.js +++ b/packages/rocketchat-ui-sidenav/client/roomList.js @@ -78,6 +78,11 @@ Template.roomList.helpers({ if (room.header || room.identifier) { return `type-${ room.header || room.identifier }`; } + }, + + showCounter() { + const user = Meteor.user(); + return user && user.settings && user.settings.preferences && user.settings.preferences.messageCounterSidebar; } }); diff --git a/server/methods/saveUserPreferences.js b/server/methods/saveUserPreferences.js index 1255fa0e3313..d14f382af632 100644 --- a/server/methods/saveUserPreferences.js +++ b/server/methods/saveUserPreferences.js @@ -82,6 +82,7 @@ Meteor.methods({ preferences.hideFlexTab = settings.hideFlexTab === '1'; preferences.highlights = settings.highlights; preferences.sendOnEnter = settings.sendOnEnter; + preferences.messageCounterSidebar = settings.messageCounterSidebar === '1'; RocketChat.models.Users.setPreferences(Meteor.userId(), preferences);