Commit 21d27bc1 by Sebastián Katzer

Fix issue and missing id in clear and cancel for windows

parent 049680a9
......@@ -62,10 +62,8 @@ exports.core = {
notification = this.build(options);
this.cancelLocalNotification(options.id);
this.scheduleLocalNotification(notification, options);
this.scheduleBackupNotification(notification, options);
this.fireEvent('schedule', options);
this.callOnTrigger(options, triggerFn);
}
......@@ -185,9 +183,10 @@ exports.core = {
*/
clear: function (ids) {
for (var i = 0; i < ids.length; i++) {
var notification = this.getAll([id])[0];
var id = ids[i],
notification = this.getAll([id])[0];
this.clearLocalNotification(ids[i]);
this.clearLocalNotification(id);
this.fireEvent('clear', notification);
}
},
......@@ -199,8 +198,13 @@ exports.core = {
* Local notification ID
*/
clearLocalNotification: function (id) {
var notification = this.getAll([id])[0];
this.getToastHistory().remove('Toast' + id);
if (this.isRepeating(notification))
return;
if (this.isTriggered(id) && !this.isScheduled(id)) {
this.cancelLocalNotification(id);
}
......@@ -228,7 +232,8 @@ exports.core = {
*/
cancel: function (ids) {
for (var i = 0; i < ids.length; i++) {
var notification = this.getAll([id])[0];
var id = ids[i],
notification = this.getAll([id])[0];
this.cancelLocalNotification(ids[i]);
this.fireEvent('cancel', notification);
......
......@@ -69,6 +69,18 @@ exports.getRepeatInterval = function (every) {
};
/**
* If the notification is repeating.
*
* @param {Object} notification
* Local notification object
*
* @return Boolean
*/
exports.isRepeating = function (notification) {
return this.getRepeatInterval(notification.every) !== 0;
};
/**
* Parses sound file path.
*
* @param {String} path
......@@ -363,7 +375,11 @@ WinJS.Application.addEventListener('activated', function (args) {
return;
exports.clearLocalNotification(id);
var repeating = exports.isRepeating(notification);
exports.fireEvent('click', notification);
exports.fireEvent(repeating ? 'clear' : 'cancel', notification);
}, false);
// App is running in background
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment