From 800004e47963c80ac7c7a518e38b570fc496495b Mon Sep 17 00:00:00 2001 From: CYCLOPS Date: Sat, 7 Oct 2017 20:29:16 +0330 Subject: [PATCH 1/5] use enter separator rather than comma in highlight preferences --- packages/rocketchat-i18n/i18n/en.i18n.json | 2 +- packages/rocketchat-ui-account/client/accountPreferences.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/rocketchat-i18n/i18n/en.i18n.json b/packages/rocketchat-i18n/i18n/en.i18n.json index 3ae244ed59cc..ea03ab0cf1a0 100644 --- a/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/packages/rocketchat-i18n/i18n/en.i18n.json @@ -779,7 +779,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 . Highlight Words are not case sensitive.", "Highlights_List": "Highlight words", "History": "History", "Host": "Host", diff --git a/packages/rocketchat-ui-account/client/accountPreferences.js b/packages/rocketchat-ui-account/client/accountPreferences.js index 1239dfac1e8f..50d0f43226bb 100644 --- a/packages/rocketchat-ui-account/client/accountPreferences.js +++ b/packages/rocketchat-ui-account/client/accountPreferences.js @@ -64,7 +64,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'); @@ -153,7 +153,7 @@ Template.accountPreferences.onCreated(function() { data.autoImageLoad = $('input[name=autoImageLoad]:checked').val(); data.emailNotificationMode = $('select[name=emailNotificationMode]').val(); - data.highlights = _.compact(_.map($('[name=highlights]').val().split(','), function(e) { + data.highlights = _.compact(_.map($('[name=highlights]').val().split('\n'), function(e) { return _.trim(e); })); data.desktopNotificationDuration = $('input[name=desktopNotificationDuration]').val(); From acf85894e4213bbd4d9ffecda7f7132aebda17a3 Mon Sep 17 00:00:00 2001 From: CYCLOPS Date: Sun, 8 Oct 2017 17:11:11 +0330 Subject: [PATCH 2/5] Auto refresh after change highlighted words from account preferences --- .../client/accountPreferences.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/rocketchat-ui-account/client/accountPreferences.js b/packages/rocketchat-ui-account/client/accountPreferences.js index 50d0f43226bb..1c1cd91ae108 100644 --- a/packages/rocketchat-ui-account/client/accountPreferences.js +++ b/packages/rocketchat-ui-account/client/accountPreferences.js @@ -153,9 +153,21 @@ Template.accountPreferences.onCreated(function() { data.autoImageLoad = $('input[name=autoImageLoad]:checked').val(); data.emailNotificationMode = $('select[name=emailNotificationMode]').val(); + data.highlights = _.compact(_.map($('[name=highlights]').val().split('\n'), function(e) { return _.trim(e); })); + + // 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; + } + data.desktopNotificationDuration = $('input[name=desktopNotificationDuration]').val(); data.desktopNotifications = $('#desktopNotifications').find('select').val(); data.mobileNotifications = $('#mobileNotifications').find('select').val(); From 80ef7f4bcb530c43ae9836887d538209779cb2f7 Mon Sep 17 00:00:00 2001 From: CYCLOPS Date: Sun, 8 Oct 2017 17:30:46 +0330 Subject: [PATCH 3/5] fix no-trailing-spaces from Codacy --- packages/rocketchat-ui-account/client/accountPreferences.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/rocketchat-ui-account/client/accountPreferences.js b/packages/rocketchat-ui-account/client/accountPreferences.js index 1c1cd91ae108..b030e209772d 100644 --- a/packages/rocketchat-ui-account/client/accountPreferences.js +++ b/packages/rocketchat-ui-account/client/accountPreferences.js @@ -153,7 +153,6 @@ Template.accountPreferences.onCreated(function() { data.autoImageLoad = $('input[name=autoImageLoad]:checked').val(); data.emailNotificationMode = $('select[name=emailNotificationMode]').val(); - data.highlights = _.compact(_.map($('[name=highlights]').val().split('\n'), function(e) { return _.trim(e); })); From a148320ac58e8127ff96b4ca13514f88344e10a3 Mon Sep 17 00:00:00 2001 From: Rodrigo Nascimento Date: Thu, 7 Dec 2017 15:26:51 -0200 Subject: [PATCH 4/5] Update accountPreferences.js --- packages/rocketchat-ui-account/client/accountPreferences.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/rocketchat-ui-account/client/accountPreferences.js b/packages/rocketchat-ui-account/client/accountPreferences.js index 4b22faf33839..658a23d85a4a 100644 --- a/packages/rocketchat-ui-account/client/accountPreferences.js +++ b/packages/rocketchat-ui-account/client/accountPreferences.js @@ -200,7 +200,7 @@ Template.accountPreferences.onCreated(function() { let reload = false; - // if highlights changed we need page reload + // if highlights changed we need page reload const user = Meteor.user(); if (user && user.settings && From d281f0c5d5b2f1721ce564997b67cb1a35664c6b Mon Sep 17 00:00:00 2001 From: Rodrigo Nascimento Date: Thu, 7 Dec 2017 15:39:24 -0200 Subject: [PATCH 5/5] Update accountPreferences.js --- packages/rocketchat-ui-account/client/accountPreferences.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/rocketchat-ui-account/client/accountPreferences.js b/packages/rocketchat-ui-account/client/accountPreferences.js index 658a23d85a4a..8dc59e2074e0 100644 --- a/packages/rocketchat-ui-account/client/accountPreferences.js +++ b/packages/rocketchat-ui-account/client/accountPreferences.js @@ -199,7 +199,7 @@ Template.accountPreferences.onCreated(function() { data.idleTimeLimit = idleTimeLimit; let reload = false; - + // if highlights changed we need page reload const user = Meteor.user(); if (user &&