Vulcan/packages/telescope-notifications/lib/client/templates/unsubscribe.js

19 lines
703 B
JavaScript
Raw Normal View History

2014-07-05 11:24:28 +09:00
Template[getTemplate('unsubscribe')].created = function(){
2013-10-09 20:26:58 +09:00
var hash = this.data.hash;
2013-01-19 21:55:10 +09:00
Meteor.call('unsubscribeUser', hash, function(error, result){
if(result){
2014-11-24 11:27:07 +09:00
Session.set('unsubscribedMessage', __('you_have_been_unsubscribed_from_all_notifications'));
2013-01-19 21:55:10 +09:00
}else{
2014-11-24 11:27:07 +09:00
Session.set('unsubscribedMessage', __('user_not_found'));
2013-01-19 21:55:10 +09:00
}
});
2013-01-19 22:15:09 +09:00
trackEvent('notificationsUnsubcribe', {hash: hash});
};
2013-01-19 21:55:10 +09:00
2014-07-05 11:24:28 +09:00
Template[getTemplate('unsubscribe')].helpers({
2013-01-19 21:37:46 +09:00
unsubscribed : function(){
2013-01-19 22:47:35 +09:00
// we have to use a session variable because the string we want to display
// depends on the return value of an asynchronous callback (unsubscribeUser)
2013-01-19 21:55:10 +09:00
return Session.get('unsubscribedMessage');
2013-01-19 21:37:46 +09:00
}
});