Skip to content

Commit

Permalink
Merge pull request #8433 from intwarehq/fix-8377
Browse files Browse the repository at this point in the history
[NEW] Use enter separator rather than comma in highlight preferences + Auto refresh after change highlighted words
  • Loading branch information
rodrigok committed Dec 7, 2017
2 parents 0cdcf89 + d281f0c commit 240278c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@
"Hide_Unread_Room_Status": "Hide Unread Room Status",
"Hide_usernames": "Hide Usernames",
"Highlights": "Highlights",
"Highlights_How_To": "To be notified when someone mentions a word or phrase, add it here. You can separate words or phrases with commas. Highlight Words are not case sensitive.",
"Highlights_How_To": "To be notified when someone mentions a word or phrase, add it here. You can separate words or phrases with <Enter>. Highlight Words are not case sensitive.",
"Highlights_List": "Highlight words",
"History": "History",
"Host": "Host",
Expand Down
15 changes: 13 additions & 2 deletions packages/rocketchat-ui-account/client/accountPreferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Template.accountPreferences.helpers({
},
highlights() {
const user = Meteor.user();
return user && user.settings && user.settings.preferences && user.settings.preferences['highlights'] && user.settings.preferences['highlights'].join(', ');
return user && user.settings && user.settings.preferences && user.settings.preferences['highlights'] && user.settings.preferences['highlights'].join('\n');
},
desktopNotificationEnabled() {
return KonchatNotification.notificationStatus.get() === 'granted' || (window.Notification && Notification.permission === 'granted');
Expand Down Expand Up @@ -187,7 +187,7 @@ Template.accountPreferences.onCreated(function() {
data.unreadAlert = $('#unreadAlert').find('input:checked').val();
data.notificationsSoundVolume = parseInt($('#notificationsSoundVolume').val());
data.roomCounterSidebar = $('#roomCounterSidebar').find('input:checked').val();
data.highlights = _.compact(_.map($('[name=highlights]').val().split(','), function(e) {
data.highlights = _.compact(_.map($('[name=highlights]').val().split('\n'), function(e) {
return s.trim(e);
}));

Expand All @@ -200,6 +200,17 @@ Template.accountPreferences.onCreated(function() {

let reload = false;

// if highlights changed we need page reload
const user = Meteor.user();
if (user &&
user.settings &&
user.settings.preferences &&
user.settings.preferences['highlights'] &&
user.settings.preferences['highlights'].join('\n') !== data.highlights.join('\n')) {
reload = true;
}


if (this.shouldUpdateLocalStorageSetting('userLanguage', selectedLanguage)) {
localStorage.setItem('userLanguage', selectedLanguage);
data.language = selectedLanguage;
Expand Down

0 comments on commit 240278c

Please sign in to comment.