Hey guys,
I’m getting the error above on the client when I call a Meteor method to clear all user notifications. This is my method:
clearNotifications: function () {
var date = new Date();
Meteor._sleepForMs(2000);
Notifications.update({toUser: this.userId, readAt:{$exists:false}}, {$set: {readAt: date}, multi:true});
}
The Notification object is available on the client side before changing the values, I’ve checked it on the console by Notifications.find().fetch().
Why do I get this error?
//Edit: The error is associated with the observer, if I remove it, everything works fine:
notifications: function () {
var lastPlay = moment();
Notifications.find().observe({
added: function (doc) {
var myMedia = new Media('application/app/sounds/notification_in.wav', function () {
});
if (!doc.hasOwnProperty("readAt") && moment().diff(lastPlay,'seconds') > 5) {
myMedia.play();
lastPlay = moment();
}
},
change: function (doc) {
var myMedia = new Media('application/app/sounds/notification_in.wav', function () {
});
if (!doc.hasOwnProperty("readAt") && moment().diff(lastPlay,'seconds') > 5) {
myMedia.play();
lastPlay = moment();
}
}
});
}