-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #606; Allows a user to disable sound notifications for new roo…
…ms and new messages
- Loading branch information
1 parent
138d6ca
commit a7edf3c
Showing
8 changed files
with
97 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
Template.accountPreferences.helpers | ||
checked: (property, value) -> | ||
currentValue = !!Meteor.user()?.settings?.preferences?[property] | ||
return currentValue is value | ||
|
||
Template.accountPreferences.onCreated -> | ||
settingsTemplate = this.parentTemplate(3) | ||
settingsTemplate.child ?= [] | ||
settingsTemplate.child.push this | ||
|
||
@clearForm = -> | ||
|
||
@save = -> | ||
instance = @ | ||
data = {} | ||
|
||
data.disableNewRoomNotification = $('input[name=disableNewRoomNotification]:checked').val() | ||
data.disableNewMessageNotification = $('input[name=disableNewMessageNotification]:checked').val() | ||
Meteor.call 'saveUserPreferences', data, (error, results) -> | ||
if results | ||
toastr.success t('Preferences_saved') | ||
instance.clearForm() | ||
|
||
if error | ||
toastr.error error.reason | ||
|
||
Template.accountPreferences.onRendered -> | ||
Tracker.afterFlush -> | ||
SideNav.setFlex "accountFlex" | ||
SideNav.openFlex() | ||
|
||
Template.accountPreferences.events | ||
'click .submit button': (e, t) -> | ||
t.save() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<template name="accountPreferences"> | ||
<section class="page-container page-home page-static"> | ||
<head class="fixed-title"> | ||
{{> burger}} | ||
<h2> | ||
<span class="room-title">{{_ "Preferences"}}</span> | ||
</h2> | ||
</head> | ||
<div class="content"> | ||
<div class="rocket-form"> | ||
<fieldset> | ||
<div class="section"> | ||
<h1>{{_ "Sound"}}</h1> | ||
<div class="section-content"> | ||
<div class="input-line double-col"> | ||
<label>{{_ "Disable_New_Room_Notification"}}</label> | ||
<div> | ||
<label><input type="radio" name="disableNewRoomNotification" value="1" checked="{{checked 'disableNewRoomNotification' true}}" /> {{_ "True"}}</label> | ||
<label><input type="radio" name="disableNewRoomNotification" value="0" checked="{{checked 'disableNewRoomNotification' false}}" /> {{_ "False"}}</label> | ||
</div> | ||
</div> | ||
<div class="input-line double-col"> | ||
<label>{{_ "Disable_New_Message_Notification"}}</label> | ||
<div> | ||
<label><input type="radio" name="disableNewMessageNotification" value="1" checked="{{checked 'disableNewMessageNotification' true}}" /> {{_ "True"}}</label> | ||
<label><input type="radio" name="disableNewMessageNotification" value="0" checked="{{checked 'disableNewMessageNotification' false}}" /> {{_ "False"}}</label> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</fieldset> | ||
<div class="submit"> | ||
<button class="button"><i class="icon-send"></i><span>{{_ "Save_changes"}}</span></button> | ||
</div> | ||
</div> | ||
</div> | ||
</section> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Meteor.methods | ||
saveUserPreferences: (settings) -> | ||
console.log '[method] saveUserPreferences', settings | ||
|
||
if Meteor.userId() | ||
preferences = {} | ||
|
||
if settings.disableNewRoomNotification? | ||
preferences.disableNewRoomNotification = if settings.disableNewRoomNotification is "1" then true else false | ||
|
||
if settings.disableNewMessageNotification? | ||
preferences.disableNewMessageNotification = if settings.disableNewMessageNotification is "1" then true else false | ||
|
||
Meteor.users.update Meteor.userId(), { $set: { "settings.preferences": preferences } } | ||
|
||
return true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,4 @@ Meteor.publish 'userData', -> | |
admin: 1 | ||
utcOffset: 1 | ||
language: 1 | ||
settings: 1 |