Skip to content

Commit

Permalink
[FIX] Remove a non working setting "Notification Duration" (#15737)
Browse files Browse the repository at this point in the history
  • Loading branch information
pierre-lehnen-rc authored May 21, 2020
1 parent 0ab8464 commit cb46fb3
Show file tree
Hide file tree
Showing 21 changed files with 22 additions and 141 deletions.
1 change: 0 additions & 1 deletion app/api/server/v1/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,6 @@ API.v1.addRoute('users.setPreferences', { authRequired: true }, {
mobileNotifications: Match.Maybe(String),
enableAutoAway: Match.Maybe(Boolean),
highlights: Match.Maybe(Array),
desktopNotificationDuration: Match.Maybe(Number),
desktopNotificationRequireInteraction: Match.Maybe(Boolean),
messageViewMode: Match.Maybe(Number),
hideUsernames: Match.Maybe(Boolean),
Expand Down
2 changes: 0 additions & 2 deletions app/lib/server/lib/sendNotificationsOnMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ export const sendNotification = async ({
user: sender,
message,
room,
duration: subscription.desktopNotificationDuration,
});
}

Expand Down Expand Up @@ -176,7 +175,6 @@ export const sendNotification = async ({
const project = {
$project: {
audioNotifications: 1,
desktopNotificationDuration: 1,
desktopNotifications: 1,
emailNotifications: 1,
mobilePushNotifications: 1,
Expand Down
5 changes: 0 additions & 5 deletions app/lib/server/startup/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,6 @@ settings.addGroup('Accounts', function() {
public: true,
i18nLabel: 'Idle_Time_Limit',
});
this.add('Accounts_Default_User_Preferences_desktopNotificationDuration', 0, {
type: 'int',
public: true,
i18nLabel: 'Notification_Duration',
});
this.add('Accounts_Default_User_Preferences_desktopNotificationRequireInteraction', false, {
type: 'boolean',
public: true,
Expand Down
16 changes: 0 additions & 16 deletions app/models/server/models/Subscriptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,20 +180,6 @@ export class Subscriptions extends Base {
return this.update(query, update);
}

updateDesktopNotificationDurationById(_id, value) {
const query = {
_id,
};

const update = {
$set: {
desktopNotificationDuration: parseInt(value),
},
};

return this.update(query, update);
}

updateMobilePushNotificationsById(_id, mobilePushNotifications) {
const query = {
_id,
Expand Down Expand Up @@ -366,7 +352,6 @@ export class Subscriptions extends Base {
ignored: 1,
audioNotifications: 1,
audioNotificationValue: 1,
desktopNotificationDuration: 1,
desktopNotifications: 1,
mobilePushNotifications: 1,
emailNotifications: 1,
Expand All @@ -393,7 +378,6 @@ export class Subscriptions extends Base {
'u._id': 1,
audioNotifications: 1,
audioNotificationValue: 1,
desktopNotificationDuration: 1,
desktopNotifications: 1,
mobilePushNotifications: 1,
emailNotifications: 1,
Expand Down
14 changes: 0 additions & 14 deletions app/push-notifications/client/views/pushNotificationsFlexTab.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,20 +101,6 @@
<i class="icon-play-circled" data-play="{{audioNotificationValue}}"></i>
{{/with}}
</div>
<div class="rc-user-info__config-content">
<div class="rc-user-info__config-name">{{_ "Notifications_Duration"}}:</div>
{{# with "desktopNotificationDuration"}}
<div class="rc-user-info__config-value">
{{#if desktopNotificationDuration }}
{{_ "Duration"}} {{desktopNotificationDuration}} {{_ "seconds"}}
{{else}}
{{_ "Use_User_Preferences_or_Global_Settings"}}
{{/if}}

{{> icon block="rc-user-info__config-content-icon" icon="arrow-down"}}
</div>
{{/with}}
</div>
</div>
</div>
<div class="rc-user-info__row rc-user-info__row--separator">
Expand Down
50 changes: 1 addition & 49 deletions app/push-notifications/client/views/pushNotificationsFlexTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@ Template.pushNotificationsFlexTab.helpers({
emailNotifications() {
return Template.instance().form.emailNotifications.get();
},
desktopNotificationDuration() {
return Template.instance().form.desktopNotificationDuration.get();
},
subValue(field) {
const { form } = Template.instance();
if (form[field]) {
Expand Down Expand Up @@ -131,7 +128,6 @@ Template.pushNotificationsFlexTab.onCreated(function() {
desktopNotifications: 1,
mobilePushNotifications: 1,
emailNotifications: 1,
desktopNotificationDuration: 1,
audioNotificationValue: 1,
muteGroupMentions: 1,
},
Expand All @@ -144,7 +140,6 @@ Template.pushNotificationsFlexTab.onCreated(function() {
desktopNotifications = 'default',
mobilePushNotifications = 'default',
emailNotifications = 'default',
desktopNotificationDuration = 0,
muteGroupMentions = false,
} = sub;

Expand All @@ -157,7 +152,6 @@ Template.pushNotificationsFlexTab.onCreated(function() {
desktopNotifications: new ReactiveVar(desktopNotifications),
mobilePushNotifications: new ReactiveVar(mobilePushNotifications),
emailNotifications: new ReactiveVar(emailNotifications),
desktopNotificationDuration: new ReactiveVar(desktopNotificationDuration),
audioNotificationValue: new ReactiveVar(audioNotificationValue),
muteGroupMentions: new ReactiveVar(muteGroupMentions),
};
Expand All @@ -169,7 +163,6 @@ Template.pushNotificationsFlexTab.onCreated(function() {
desktopNotifications: new ReactiveVar(desktopNotifications),
mobilePushNotifications: new ReactiveVar(mobilePushNotifications),
emailNotifications: new ReactiveVar(emailNotifications),
desktopNotificationDuration: new ReactiveVar(desktopNotificationDuration),
audioNotificationValue: new ReactiveVar(audioNotificationValue),
muteGroupMentions: new ReactiveVar(muteGroupMentions),
};
Expand All @@ -186,9 +179,6 @@ Template.pushNotificationsFlexTab.onCreated(function() {
}
const rid = Session.get('openedRoom');
switch (field) {
case 'desktopNotificationDuration':
await call('saveDesktopNotificationDuration', rid, value);
break;
case 'audioNotificationValue':
await call('saveAudioNotificationValue', rid, value.split(' ')[0]);
break;
Expand Down Expand Up @@ -262,44 +252,6 @@ Template.pushNotificationsFlexTab.events({
...audioAssetsArray,
];
break;
case 'desktopNotificationDuration':
options = [{
id: 'desktopNotificationDuration',
name: 'desktopNotificationDuration',
label: 'Default',
value: 0,
},
{
id: 'desktopNotificationDuration1s',
name: 'desktopNotificationDuration',
label: `1 ${ t('seconds') }`,
value: 1,
},
{
id: 'desktopNotificationDuration2s',
name: 'desktopNotificationDuration',
label: `2 ${ t('seconds') }`,
value: 2,
},
{
id: 'desktopNotificationDuration3s',
name: 'desktopNotificationDuration',
label: `3 ${ t('seconds') }`,
value: 3,
},
{
id: 'desktopNotificationDuration4s',
name: 'desktopNotificationDuration',
label: `4 ${ t('seconds') }`,
value: 4,
},
{
id: 'desktopNotificationDuration5s',
name: 'desktopNotificationDuration',
label: `5 ${ t('seconds') }`,
value: 5,
}];
break;
default:
options = [{
id: 'desktopNotificationsDefault',
Expand Down Expand Up @@ -331,7 +283,7 @@ Template.pushNotificationsFlexTab.events({
popoverClass: 'notifications-preferences',
template: 'pushNotificationsPopover',
data: {
change: (value) => instance.form[key].set(key === 'desktopNotificationDuration' ? parseInt(value) : value),
change: (value) => instance.form[key].set(value),
value: instance.form[key].get(),
options,
},
Expand Down
12 changes: 0 additions & 12 deletions app/push-notifications/server/methods/saveNotificationSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@ Meteor.methods({
muteGroupMentions: {
updateMethod: (subscription, value) => Subscriptions.updateMuteGroupMentions(subscription._id, value === '1'),
},
desktopNotificationDuration: {
updateMethod: (subscription, value) => Subscriptions.updateDesktopNotificationDurationById(subscription._id, value),
},
audioNotificationValue: {
updateMethod: (subscription, value) => Subscriptions.updateAudioNotificationValueById(subscription._id, value),
},
Expand Down Expand Up @@ -96,13 +93,4 @@ Meteor.methods({
Subscriptions.updateAudioNotificationValueById(subscription._id, value);
return true;
},

saveDesktopNotificationDuration(rid, value) {
const subscription = Subscriptions.findOneByRoomIdAndUserId(rid, Meteor.userId());
if (!subscription) {
throw new Meteor.Error('error-invalid-subscription', 'Invalid subscription', { method: 'saveDesktopNotificationDuration' });
}
Subscriptions.updateDesktopNotificationDurationById(subscription._id, value);
return true;
},
});
10 changes: 0 additions & 10 deletions app/ui-account/client/accountPreferences.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,6 @@ <h1>{{_ "Notifications"}}</h1>
{{/if}}
</div>
</div>
<div class="input-line double-col">
<label class="setting-label">{{_ "Notification_Duration"}}</label>
<div class="setting-field">
{{#if desktopNotificationDuration}}
<input type="number" class="rc-input__element" name="desktopNotificationDuration" min="0" value="{{desktopNotificationDuration}}">
{{else}}
<input type="number" class="rc-input__element" name="desktopNotificationDuration" min="0" value="" placeholder="{{_ "Use_Global_Settings"}} ({{defaultDesktopNotificationDuration}})">
{{/if}}
</div>
</div>
<div class="input-line double-col" id="desktopNotificationRequireInteraction">
<label class="setting-label">{{_ "Notification_RequireInteraction"}}</label>
<div class="setting-field">
Expand Down
9 changes: 0 additions & 9 deletions app/ui-account/client/accountPreferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,6 @@ Template.accountPreferences.helpers({
desktopNotificationDisabled() {
return KonchatNotification.notificationStatus.get() === 'denied' || (window.Notification && Notification.permission === 'denied');
},
desktopNotificationDuration() {
const userPref = getUserPreference(Meteor.userId(), 'desktopNotificationDuration', 'undefined');
return userPref !== 'undefined' ? userPref : undefined;
},
defaultDesktopNotificationDuration() {
return settings.get('Accounts_Default_User_Preferences_desktopNotificationDuration');
},
desktopNotificationRequireInteraction() {
const userPref = getUserPreference(Meteor.userId(), 'desktopNotificationRequireInteraction', 'undefined');
return userPref !== 'undefined' ? userPref : undefined;
Expand Down Expand Up @@ -178,7 +171,6 @@ Template.accountPreferences.onCreated(function() {
data.sendOnEnter = $('#sendOnEnter').find('select').val();
data.autoImageLoad = JSON.parse($('input[name=autoImageLoad]:checked').val());
data.emailNotificationMode = $('select[name=emailNotificationMode]').val();
data.desktopNotificationDuration = $('input[name=desktopNotificationDuration]').val() === '' ? settings.get('Accounts_Default_User_Preferences_desktopNotificationDuration') : parseInt($('input[name=desktopNotificationDuration]').val());
data.desktopNotifications = $('#desktopNotifications').find('select').val();
data.mobileNotifications = $('#mobileNotifications').find('select').val();
data.unreadAlert = JSON.parse($('#unreadAlert').find('input:checked').val());
Expand Down Expand Up @@ -330,7 +322,6 @@ Template.accountPreferences.events({
'click .js-test-notifications'(e) {
e.preventDefault();
KonchatNotification.notify({
duration: $('input[name=desktopNotificationDuration]').val(),
payload: { sender: { username: 'rocket.cat' },
},
title: TAPi18n.__('Desktop_Notification_Test'),
Expand Down
2 changes: 1 addition & 1 deletion app/ui/client/lib/notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const KonchatNotification = {
requireInteraction: getUserPreference(Meteor.userId(), 'desktopNotificationRequireInteraction'),
});

const notificationDuration = notification.duration - 0 || getUserPreference(Meteor.userId(), 'desktopNotificationDuration') - 0;
const notificationDuration = notification.duration - 0 || 10;
if (notificationDuration > 0) {
setTimeout(() => n.close(), notificationDuration * 1000);
}
Expand Down
3 changes: 0 additions & 3 deletions packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -1239,7 +1239,6 @@
"Duplicated_Email_address_will_be_ignored": "Duplicated email address will be ignored.",
"Duplicate_file_name_found": "Duplicate file name found.",
"Duplicate_private_group_name": "A Private Group with name '%s' exists",
"Duration": "Duration",
"E2E Encryption": "E2E Encryption",
"E2E_Enabled": "E2E Enabled",
"E2E_Enable_alert": "This feature is currently in beta! Please report bugs to github.com/RocketChat/Rocket.Chat/issues and be aware of:<br/>- Encrypted messages of encrypted rooms will not be found by search operations.<br/>- The mobile apps may not support the encypted messages (they are implementing it).<br/>- Bots may not be able to see encrypted messages until they implement support for it.<br/>- Uploads will not be encrypted in this version.",
Expand Down Expand Up @@ -2537,12 +2536,10 @@
"Nothing_found": "Nothing found",
"Not_Imported_Messages_Title": "The following messages were not imported successfully",
"Notification_Desktop_Default_For": "Show Desktop Notifications For",
"Notification_Duration": "Notification Duration",
"Notification_RequireInteraction": "Require Interaction to Dismiss Desktop Notification",
"Notification_RequireInteraction_Description": "Works only with Chrome browser versions > 50. Utilizes the parameter <i>requireInteraction</i> to show the desktop notification to indefinite until the user interacts with it.",
"Notification_Mobile_Default_For": "Push Mobile Notifications For",
"Notifications": "Notifications",
"Notifications_Duration": "Notifications Duration",
"Notifications_Max_Room_Members": "Max Room Members Before Disabling All Message Notifications",
"Notifications_Max_Room_Members_Description": "Max number of members in room when notifications for all messages gets disabled. Users can still change per room setting to receive all notifications on an individual basis. (0 to disable)",
"Notifications_Muted_Description": "If you choose to mute everything, you won't see the room highlight in the list when there are new messages, except for mentions. Muting notifications will override notifications settings.",
Expand Down
1 change: 0 additions & 1 deletion server/methods/saveUserPreferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ Meteor.methods({
mobileNotifications: Match.Optional(String),
enableAutoAway: Match.Optional(Boolean),
highlights: Match.Optional([String]),
desktopNotificationDuration: Match.Optional(Number),
messageViewMode: Match.Optional(Number),
hideUsernames: Match.Optional(Boolean),
hideRoles: Match.Optional(Boolean),
Expand Down
1 change: 0 additions & 1 deletion server/publications/subscription/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export const fields = {
audioNotifications: 1,
audioNotificationValue: 1,
desktopNotifications: 1,
desktopNotificationDuration: 1,
mobilePushNotifications: 1,
emailNotifications: 1,
unreadAlert: 1,
Expand Down
1 change: 1 addition & 0 deletions server/startup/migrations/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,5 @@ import './v186';
import './v187';
import './v188';
import './v189';
import './v190';
import './xrun';
1 change: 0 additions & 1 deletion server/startup/migrations/v105.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ Migrations.add({
Desktop_Notifications_Default_Alert: 'Accounts_Default_User_Preferences_desktopNotifications',
Mobile_Notifications_Default_Alert: 'Accounts_Default_User_Preferences_mobileNotifications',
Audio_Notifications_Default_Alert: 'Accounts_Default_User_Preferences_audioNotifications',
Desktop_Notifications_Duration: 'Accounts_Default_User_Preferences_desktopNotificationDuration',
Audio_Notifications_Value: undefined,
};
Settings.find({ _id: { $in: Object.keys(settingsMap) } }).forEach((oldSetting) => {
Expand Down
19 changes: 19 additions & 0 deletions server/startup/migrations/v190.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Migrations } from '../../../app/migrations';
import { Settings, Subscriptions } from '../../../app/models/server/raw';

Migrations.add({
version: 190,
up() {
// Remove unused settings
Promise.await(Settings.col.deleteOne({ _id: 'Accounts_Default_User_Preferences_desktopNotificationDuration' }));
Promise.await(Subscriptions.col.updateMany({
desktopNotificationDuration: {
$exists: true,
},
}, {
$unset: {
desktopNotificationDuration: 1,
},
}));
},
});
9 changes: 0 additions & 9 deletions tests/cypress/integration/11-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -683,15 +683,6 @@ describe('[Administration]', () => {
admin.accountsidleTimeLimit.should('have.value', '300');
});

it('it should show the notifications durations field', () => {
admin.accountsNotificationDuration.click();
admin.accountsNotificationDuration.should('be.visible');
});

it('the notification duration field value should be 0', () => {
admin.accountsNotificationDuration.should('have.value', '0');
});

it('it should show the audio notifications select field', () => {
admin.accountsAudioNotifications.scrollIntoView();
admin.accountsAudioNotifications.should('be.visible');
Expand Down
4 changes: 0 additions & 4 deletions tests/cypress/pageobjects/administration.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,6 @@ class Administration extends Page {

get accountsidleTimeLimitReset() { return browser.element('[data-qa-reset-setting-id="Accounts_Default_User_Preferences_idleTimeLimit"]'); }

get accountsNotificationDuration() { return browser.element('[data-qa-setting-id="Accounts_Default_User_Preferences_desktopNotificationDuration"]'); }

get accountsNotificationDurationReset() { return browser.element('[data-qa-reset-setting-id="Accounts_Default_User_Preferences_desktopNotificationDuration"]'); }

get accountsAudioNotifications() { return browser.element('[data-qa-setting-id="Accounts_Default_User_Preferences_audioNotifications"]'); }

get accountsAudioNotificationsReset() { return browser.element('[data-qa-reset-setting-id="Accounts_Default_User_Preferences_audioNotifications"]'); }
Expand Down
1 change: 0 additions & 1 deletion tests/data/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export const preferences = {
mobileNotifications: 'default',
enableAutoAway: true,
highlights: [],
desktopNotificationDuration: 0,
desktopNotificationRequireInteraction: false,
messageViewMode: 0,
hideUsernames: false,
Expand Down
1 change: 0 additions & 1 deletion tests/end-to-end/api/00-miscellaneous.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ describe('miscellaneous', function() {
'mobileNotifications',
'enableAutoAway',
// 'highlights',
'desktopNotificationDuration',
'desktopNotificationRequireInteraction',
'messageViewMode',
'hideUsernames',
Expand Down
Loading

0 comments on commit cb46fb3

Please sign in to comment.