Skip to content

Commit

Permalink
Merge pull request #8866 from RocketChat/message-counter-sidebar
Browse files Browse the repository at this point in the history
[NEW] Room counter sidebar preference
  • Loading branch information
rodrigok committed Dec 4, 2017
2 parents 4aac05b + 7ef142b commit 9de8e34
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 5 deletions.
2 changes: 2 additions & 0 deletions packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -1631,6 +1631,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",
Expand All @@ -1641,6 +1642,7 @@
"Showing_archived_results": "<p>Showing <b>%s</b> archived results</p>",
"Showing_online_users": "Showing: <b>__total_showing__</b>, Online: __online__, Total: __total__ users",
"Showing_results": "<p>Showing <b>%s</b> results</p>",
"Sidebar": "Sidebar",
"Sidebar_list_mode": "Sidebar Channel List Mode",
"Sign_in_to_start_talking": "Sign in to start talking",
"since_creation": "since %s",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

font-size: var(--rooms-list-title-text-size);
align-items: center;
justify-content: space-between;

&-text--livechat {
flex: 1;
Expand Down
12 changes: 12 additions & 0 deletions packages/rocketchat-ui-account/client/accountPreferences.html
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,18 @@ <h1>{{_ "Messages"}}</h1>
</div>
</div>
</div>
<div class="section">
<h1>{{_ "Sidebar"}}</h1>
<div class="section-content border-component-color">
<div class="input-line double-col" id="messageCounterSidebar">
<label>{{_ "Show_message_counter_on_sidebar"}}</label>
<div>
<label><input type="radio" name="messageCounterSidebar" value="1" checked="{{checked 'messageCounterSidebar' true}}"/> {{_ "True"}}</label>
<label><input type="radio" name="messageCounterSidebar" value="0" checked="{{checked 'messageCounterSidebar' false true}}"/> {{_ "False"}}</label>
</div>
</div>
</div>
</div>
<div class="section">
<h1>{{_ "Highlights"}}</h1>
<div class="section-content border-component-color">
Expand Down
2 changes: 2 additions & 0 deletions packages/rocketchat-ui-account/client/accountPreferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
12 changes: 7 additions & 5 deletions packages/rocketchat-ui-sidenav/client/roomList.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
{{#if shouldAppear .. .}}
<h3 class="rooms-list__type">
<span class="rooms-list__type-text">{{_ ../label}}</span>
{{#with count}}
{{#if .}}
<span class="badge">{{.}}</span>
{{/if}}
{{/with}}
{{#if showCounter}}
{{#with count}}
{{#if .}}
<span class="badge">{{.}}</span>
{{/if}}
{{/with}}
{{/if}}
</h3>
<ul class="rooms-list__list {{ roomType ..}}">
{{#each room in this}}
Expand Down
5 changes: 5 additions & 0 deletions packages/rocketchat-ui-sidenav/client/roomList.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,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;
}
});

Expand Down
1 change: 1 addition & 0 deletions server/methods/saveUserPreferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 9de8e34

Please sign in to comment.