notification mute

pull/9312/head
RationalCoding 7 years ago
parent 7057486a46
commit f694d66a50
  1. 18
      client/notifications/notification.js
  2. 2
      packages/rocketchat-i18n/i18n/en.i18n.json
  3. 16
      packages/rocketchat-lib/server/startup/settings.js
  4. 13
      packages/rocketchat-ui-account/client/accountPreferences.html
  5. 6
      packages/rocketchat-ui-account/client/accountPreferences.js
  6. 32
      packages/rocketchat-ui/client/lib/focusWindow.js
  7. 12
      packages/rocketchat-ui/client/lib/notification.js
  8. 1
      packages/rocketchat-ui/package.js
  9. 4
      server/methods/saveUserPreferences.js
  10. 5
      tests/pageobjects/administration.page.js

@ -29,6 +29,7 @@ Meteor.startup(function() {
// This logic is duplicated in /client/startup/unread.coffee.
const hasFocus = readMessage.isEnable();
const messageIsInOpenedRoom = openedRoomId === notification.payload.rid;
const muteFocusedConversations = RocketChat.getUserPreference(Meteor.user(), 'muteFocusedConversations');
fireGlobalEvent('notification', {
notification,
@ -42,10 +43,14 @@ Meteor.startup(function() {
KonchatNotification.newMessage(notification.payload.rid);
KonchatNotification.showDesktop(notification);
}
} else if (!(hasFocus && messageIsInOpenedRoom)) {
// Play a sound and show a notification.
KonchatNotification.newMessage(notification.payload.rid);
KonchatNotification.showDesktop(notification);
} else {
// Play a sound and show a notification.
KonchatNotification.newMessage(notification.payload.rid);
KonchatNotification.showDesktop(notification);
} else if (!muteFocusedConversations) {
// Play a notification sound
KonchatNotification.newMessage(notification.payload.rid);
}
}
});
@ -59,11 +64,10 @@ Meteor.startup(function() {
if (RocketChat.Layout.isEmbedded()) {
if (!hasFocus && messageIsInOpenedRoom) {
// Play a sound and show a notification.
// Play a notification sound
KonchatNotification.newMessage(notification.payload.rid);
}
} else if (!(hasFocus && messageIsInOpenedRoom)) {
// Play a sound and show a notification.
// Play a notification sound
KonchatNotification.newMessage(notification.payload.rid);
}
});

@ -734,7 +734,6 @@
"FileUpload_Storage_Type": "Storage Type",
"First_Channel_After_Login": "First Channel After Login",
"Flags": "Flags",
"Focus_Window_Notification": "Focus Window Notification",
"Follow_social_profiles": "Follow our social profiles, fork us on github and share your thoughts about the rocket.chat app on our trello board.",
"Fonts": "Fonts",
"Food_and_Drink": "Food & Drink",
@ -1276,6 +1275,7 @@
"multi_line": "multi line",
"mute-user": "Mute User",
"mute-user_description": "Permission to mute other users in the same channel",
"Mute_Focused_Conversations": "Mute Focused Conversations",
"Mute_someone_in_room": "Mute someone in the room",
"Mute_user": "Mute user",
"Muted": "Muted",

@ -402,20 +402,10 @@ RocketChat.settings.addGroup('Accounts', function() {
'public': true,
i18nLabel: 'New_Message_Notification'
});
this.add('Accounts_Default_User_Preferences_focusWindowNotification', 'none', {
type: 'select',
values: [
{
key: 'none',
i18nLabel: 'None'
},
{
key: 'chime',
i18nLabel: 'Default'
}
],
this.add('Accounts_Default_User_Preferences_muteFocusedConversations', true, {
type: 'boolean',
'public': true,
i18nLabel: 'Focus_Window_Notification'
i18nLabel: 'Mute_Focused_Conversations'
});
this.add('Accounts_Default_User_Preferences_notificationsSoundVolume', 100, {
type: 'int',

@ -276,16 +276,11 @@
</select>
</div>
</div>
<div class="input-line double-col">
<label>{{_ "Focus_Window_Notification"}}</label>
<div class="input-line double-col" id="muteFocusedConversations">
<label>{{_ "Mute_Focused_Conversations"}}</label>
<div>
<select name="focusWindowNotification" class="audio">
<option value="none" selected="{{$eq focusWindowNotification 'none'}}">{{_ "None"}} ({{_ "Default"}})</option>
<option value="chime" selected="{{$eq focusWindowNotification 'chime'}}">Chime</option>
{{#each audioAssets}}
<option value="{{_id}}" selected="{{$eq focusWindowNotification _id}}">{{name}}</option>
{{/each}}
</select>
<label><input type="radio" name="muteFocusedConversations" value="1" checked="{{checked 'muteFocusedConversations' true}}"/> {{_ "True"}}</label>
<label><input type="radio" name="muteFocusedConversations" value="0" checked="{{checked 'muteFocusedConversations' false}}"/> {{_ "False"}}</label>
</div>
</div>
<div class="input-line double-col">

@ -29,8 +29,8 @@ Template.accountPreferences.helpers({
newRoomNotification() {
return RocketChat.getUserPreference(Meteor.user(), 'newRoomNotification');
},
focusWindowNotification() {
return RocketChat.getUserPreference(Meteor.user(), 'focusWindowNotification');
muteFocusedConversations() {
return RocketChat.getUserPreference(Meteor.user(), 'muteFocusedConversations');
},
languages() {
const languages = TAPi18n.getLanguages();
@ -132,7 +132,7 @@ Template.accountPreferences.onCreated(function() {
data.newRoomNotification = $('select[name=newRoomNotification]').val();
data.newMessageNotification = $('select[name=newMessageNotification]').val();
data.focusWindowNotification = $('select[name=focusWindowNotification]').val();
data.muteFocusedConversations = $('#muteFocusedConversations').find('input:checked').val();
data.useEmojis = $('input[name=useEmojis]:checked').val();
data.convertAsciiEmoji = $('input[name=convertAsciiEmoji]:checked').val();
data.saveMobileBandwidth = $('input[name=saveMobileBandwidth]:checked').val();

@ -1,32 +0,0 @@
/* globals KonchatNotification */
const focusWindow = new class {
constructor() {
this.debug = false;
this.isFocused = true;
}
blur() {
return this.isFocused = false;
}
focus() {
if (!this.isFocused) {
KonchatNotification.focusWindow();
}
return this.isFocused = true;
}
};
Meteor.startup(function() {
$(window).on('blur', () => {
focusWindow.blur();
});
$(window).on('focus', () => {
focusWindow.focus();
});
});
export { focusWindow };
this.focusWindow = focusWindow;

@ -104,18 +104,6 @@ const KonchatNotification = {
}
},
focusWindow() {
const user = Meteor.user();
const focusWindowNotification = RocketChat.getUserPreference(user, 'focusWindowNotification');
const audioVolume = RocketChat.getUserPreference(user, 'notificationsSoundVolume');
const [audio] = $(`audio#${ focusWindowNotification }`);
if (audio && audio.play) {
audio.volume = Number((audioVolume/100).toPrecision(2));
return audio.play();
}
},
newRoom(rid/*, withSound = true*/) {
Tracker.nonreactive(function() {
let newRoomSound = Session.get('newRoomSound');

@ -51,7 +51,6 @@ Package.onUse(function(api) {
api.addFiles('client/lib/notification.js', 'client');
api.addFiles('client/lib/parentTemplate.js', 'client');
api.addFiles('client/lib/readMessages.js', 'client');
api.addFiles('client/lib/focusWindow.js', 'client');
api.addFiles('client/lib/rocket.js', 'client');
api.addFiles('client/lib/RoomHistoryManager.js', 'client');
api.addFiles('client/lib/RoomManager.js', 'client');

@ -17,8 +17,8 @@ Meteor.methods({
preferences.newMessageNotification = settings.newMessageNotification;
}
if (settings.focusWindowNotification) {
preferences.focusWindowNotification = settings.focusWindowNotification;
if (settings.muteFocusedConversations) {
preferences.muteFocusedConversations = settings.muteFocusedConversations === '1' ? true : false;
}
if (settings.useEmojis) {

@ -211,8 +211,9 @@ class Administration extends Page {
get accountsNewMessageNotification() { return browser.element('[name="Accounts_Default_User_Preferences_newMessageNotification"]'); }
get accountsNewMessageNotificationReset() { return browser.element('.reset-setting[data-setting="Accounts_Default_User_Preferences_newMessageNotification"]'); }
get accountsFocusWindowNotification() { return browser.element('[name="Accounts_Default_User_Preferences_focusWindowNotification"]'); }
get accountsFocusWindowNotificationReset() { return browser.element('.reset-setting[data-setting="Accounts_Default_User_Preferences_focusWindowNotification"]'); }
get accountsMuteFocusedConversationsTrue() { return browser.element('label:nth-of-type(1) [name="Accounts_Default_User_Preferences_muteFocusedConversations"]'); }
get accountsMuteFocusedConversationsFalse() { return browser.element('label:nth-of-type(2) [name="Accounts_Default_User_Preferences_muteFocusedConversations"]'); }
get accountsMuteFocusedConversationsReset() { return browser.element('.reset-setting[data-setting="Accounts_Default_User_Preferences_muteFocusedConversations"]'); }
get accountsNotificationsSoundVolume() { return browser.element('[name="Accounts_Default_User_Preferences_notificationsSoundVolume"]'); }
get accountsNotificationsSoundVolumeReset() { return browser.element('.reset-setting[data-setting="Accounts_Default_User_Preferences_notificationsSoundVolume"]'); }

Loading…
Cancel
Save