Commit 21d27bc1 authored by Sebastián Katzer's avatar Sebastián Katzer
Browse files

Fix issue and missing id in clear and cancel for windows

parent 049680a9
Loading
Loading
Loading
Loading
+10 −5
Changes for src/windows/LocalNotificationCore.js: 10 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -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);
+16 −0
Changes for src/windows/LocalNotificationUtil.js: 16 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -68,6 +68,18 @@ exports.getRepeatInterval = function (every) {
    return 0;
};

/**
 * 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.
 *
@@ -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