2013-01-19 21:55:10 +09:00
|
|
|
Template.unsubscribe.created = function(){
|
|
|
|
var hash = Session.get('userEmailHash');
|
|
|
|
Meteor.call('unsubscribeUser', hash, function(error, result){
|
|
|
|
if(result){
|
|
|
|
Session.set('unsubscribedMessage', 'You have been unsubscribed from all notifications.');
|
|
|
|
}else{
|
|
|
|
Session.set('unsubscribedMessage', 'User not found.');
|
|
|
|
}
|
|
|
|
});
|
2013-01-19 22:15:09 +09:00
|
|
|
trackEvent('notificationsUnsubcribe', {hash: hash});
|
2013-01-19 21:55:10 +09:00
|
|
|
}
|
|
|
|
|
2013-01-19 21:37:46 +09:00
|
|
|
Template.unsubscribe.helpers({
|
|
|
|
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
|
|
|
}
|
|
|
|
});
|