Skip to content
Snippets Groups Projects
Unverified Commit 6def9c71 authored by Marcelo Schmidt's avatar Marcelo Schmidt
Browse files

Add user preferences for default new message sound;

Renamed sound files
parent 63a1901a
No related branches found
No related tags found
No related merge requests found
Showing
with 43 additions and 24 deletions
......@@ -13,7 +13,8 @@
<label>
<select name="audioNotifications" class="audio">
<option value="none" selected="{{$eq audioNotifications 'none'}}">{{_ "None"}}</option>
<option value="defaultAudioNotification" selected="{{$eq audioNotifications 'defaultAudioNotification'}}">{{_ "Default"}}</option>
<option value="" selected="{{$eq audioNotifications ''}}">{{_ "Use_account_preference"}} ({{_ "Default"}})</option>
<option value="chime" selected="{{$eq audioNotifications 'chime'}}">Chime</option>
{{#each audioAssets}}
<option value="{{_id}}" selected="{{$eq audioNotifications _id}}">{{name}}</option>
{{/each}}
......
......@@ -13,9 +13,8 @@ Template.pushNotificationsFlexTab.helpers({
audioNotifications: 1
}
});
return sub ? sub.audioNotifications : 'defaultAudioNotification';
return sub ? sub.audioNotifications : '';
},
desktopNotifications() {
var sub = ChatSubscription.findOne({
rid: Session.get('openedRoom')
......@@ -92,11 +91,11 @@ Template.pushNotificationsFlexTab.helpers({
audioNotifications: 1
}
});
const audio = sub ? sub.audioNotifications : 'defaultAudioNotification';
const audio = sub ? sub.audioNotifications : '';
if (audio === 'none') {
return t('None');
} else if (audio === 'defaultAudioNotification') {
return t('Default');
} else if (audio === '') {
return t('Use_account_preference');
} else {
const asset = _.findWhere(KonchatNotification.audioAssets, { _id: audio });
return asset && asset.name;
......
import toastr from 'toastr'
Template.accountPreferences.helpers
audioAssets: ->
return KonchatNotification.audioAssets
audioNotifications: ->
return Meteor.user()?.settings?.preferences?.audioNotifications || 'chime'
languages: ->
languages = TAPi18n.getLanguages()
result = []
......@@ -67,7 +73,7 @@ Template.accountPreferences.onCreated ->
reload = true
data.newRoomNotification = $('input[name=newRoomNotification]:checked').val()
data.newMessageNotification = $('input[name=newMessageNotification]:checked').val()
data.audioNotifications = $('select[name=audioNotifications]').val()
data.useEmojis = $('input[name=useEmojis]:checked').val()
data.convertAsciiEmoji = $('input[name=convertAsciiEmoji]:checked').val()
data.saveMobileBandwidth = $('input[name=saveMobileBandwidth]:checked').val()
......@@ -119,3 +125,12 @@ Template.accountPreferences.events
username: 'rocket.cat'
title: TAPi18n.__('Desktop_Notification_Test')
text: TAPi18n.__('This_is_a_desktop_notification')
'change select[name=audioNotifications]': (e) ->
e.preventDefault()
audio = $(e.currentTarget).val()
if audio is 'none'
return
$audio = $('#' + (audio || 'chime'))
$audio?[0]?.play()
......@@ -178,8 +178,13 @@
<div class="input-line double-col">
<label>{{_ "New_Message_Notification"}}</label>
<div>
<label><input type="radio" name="newMessageNotification" value="1" checked="{{checked 'newMessageNotification' true true}}" /> {{_ "True"}}</label>
<label><input type="radio" name="newMessageNotification" value="0" checked="{{checked 'newMessageNotification' false}}" /> {{_ "False"}}</label>
<select name="audioNotifications" class="audio">
<option value="none" selected="{{$eq audioNotifications 'none'}}">{{_ "None"}}</option>
<option value="chime" selected="{{$eq audioNotifications 'chime'}}">Chime ({{_ "Default"}})</option>
{{#each audioAssets}}
<option value="{{_id}}" selected="{{$eq audioNotifications _id}}">{{name}}</option>
{{/each}}
</select>
</div>
</div>
</div>
......
......@@ -3,13 +3,13 @@
notificationStatus: new ReactiveVar
audioAssets: [
{ '_id': 'chatBeep02', 'name': 'Beep 2', 'sources': [ { 'src': 'sounds/beep.mp3', 'type': 'audio/mpeg' } ] }
{ '_id': 'chatBeep03', 'name': 'Beep 3', 'sources': [ { 'src': 'sounds/ding.mp3', 'type': 'audio/mpeg' } ] }
{ '_id': 'chatBeep04', 'name': 'Beep 4', 'sources': [ { 'src': 'sounds/335908__littlerainyseasons__correct.mp3', 'type': 'audio/mpeg' } ] }
{ '_id': 'chatBeep05', 'name': 'Beep 5', 'sources': [ { 'src': 'sounds/320202__chelle19__dingmp3.mp3', 'type': 'audio/mpeg' } ] }
{ '_id': 'chatBeep06', 'name': 'Beep 6', 'sources': [ { 'src': 'sounds/218851__kellyconidi__highbell.mp3', 'type': 'audio/mpeg' } ] }
{ '_id': 'chatBeep07', 'name': 'Beep 7', 'sources': [ { 'src': 'sounds/167346__willy-ineedthatapp-com__droplet-good5.mp3', 'type': 'audio/mpeg' } ] }
{ '_id': 'verbal', 'name': 'Verbal Ding', 'sources': [ { 'src': 'sounds/179132__alphahog__ding.mp3', 'type': 'audio/mpeg' } ] }
{ '_id': 'beep', 'name': 'Beep', 'sources': [ { 'src': 'sounds/beep.mp3', 'type': 'audio/mpeg' } ] }
{ '_id': 'ding', 'name': 'Ding', 'sources': [ { 'src': 'sounds/ding.mp3', 'type': 'audio/mpeg' } ] }
{ '_id': 'seasons', 'name': 'Seasons', 'sources': [ { 'src': 'sounds/seasons.mp3', 'type': 'audio/mpeg' } ] }
{ '_id': 'chelle', 'name': 'Chelle', 'sources': [ { 'src': 'sounds/chelle.mp3', 'type': 'audio/mpeg' } ] }
{ '_id': 'highbell', 'name': 'High Bell', 'sources': [ { 'src': 'sounds/highbell.mp3', 'type': 'audio/mpeg' } ] }
{ '_id': 'droplet', 'name': 'Droplet', 'sources': [ { 'src': 'sounds/droplet.mp3', 'type': 'audio/mpeg' } ] }
{ '_id': 'verbal', 'name': 'Verbal', 'sources': [ { 'src': 'sounds/verbal.mp3', 'type': 'audio/mpeg' } ] }
]
# notificacoes HTML5
......@@ -58,13 +58,13 @@
KonchatNotification.notify(notification)
newMessage: ->
if not Session.equals('user_' + Meteor.userId() + '_status', 'busy') and Meteor.user()?.settings?.preferences?.newMessageNotification isnt false
if not Session.equals('user_' + Meteor.userId() + '_status', 'busy') and Meteor.user()?.settings?.preferences?.audioNotifications isnt 'none'
sub = ChatSubscription.findOne({ rid: Session.get('openedRoom') }, { fields: { audioNotifications: 1 } });
if sub?.audioNotifications isnt 'none'
if sub?.audioNotifications
$("##{sub.audioNotifications}")[0].play()
else
$('#defaultAudioNotification')[0].play()
$('#chime')[0].play()
newRoom: (rid, withSound = true) ->
Tracker.nonreactive ->
......
<template name="audioNotification">
<audio id="defaultAudioNotification" preload>
<source src="sounds/notify.ogg" type="audio/ogg" />
<source src="sounds/notify.mp3" type="audio/mpeg" />
<audio id="chime" preload>
<source src="sounds/chime.mp3" type="audio/mpeg" />
</audio>
<audio id="chatNewRoomNotification" preload>
<source src="sounds/door_chime.mp3" type="audio/mpeg" />
<source src="sounds/door.mp3" type="audio/mpeg" />
</audio>
{{#each audioAssets}}
<audio id="{{_id}}" preload>
......
File moved
File added
File moved
File deleted
File deleted
File moved
......@@ -12,8 +12,8 @@ Meteor.methods
if settings.newRoomNotification?
preferences.newRoomNotification = if settings.newRoomNotification is "1" then true else false
if settings.newMessageNotification?
preferences.newMessageNotification = if settings.newMessageNotification is "1" then true else false
if settings.audioNotifications?
preferences.audioNotifications = settings.audioNotifications
if settings.useEmojis?
preferences.useEmojis = if settings.useEmojis is "1" then true else false
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment