From 1867635e0d13c8a5ffe9415990778b2318e50a41 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Fri, 26 Jan 2018 11:24:19 -0500 Subject: [PATCH] code review: fix updating of non-hosts resources --- src/js/assets.js | 9 +++++---- src/js/storage.js | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/js/assets.js b/src/js/assets.js index 0c33e94..0458813 100644 --- a/src/js/assets.js +++ b/src/js/assets.js @@ -53,9 +53,10 @@ api.removeObserver = function(observer) { var fireNotification = function(topic, details) { var result; - for ( var i = 0; i < observers.length; i++ ) { - if ( observers[i](topic, details) === false ) { - result = false; + for ( let i = 0; i < observers.length; i++ ) { + let r = observers[i](topic, details); + if ( r !== undefined && result === undefined ) { + result = r; } } return result; @@ -821,7 +822,7 @@ var updateNext = function() { if ( cacheEntry && (cacheEntry.writeTime + assetEntry.updateAfter * 86400000) > now ) { continue; } - if ( fireNotification('before-asset-updated', { assetKey: assetKey }) !== false ) { + if ( fireNotification('before-asset-updated', { assetKey: assetKey }) ) { return assetKey; } garbageCollectOne(assetKey); diff --git a/src/js/storage.js b/src/js/storage.js index 7bb2a13..f66d2c9 100644 --- a/src/js/storage.js +++ b/src/js/storage.js @@ -558,9 +558,9 @@ if ( topic === 'before-asset-updated' ) { if ( this.liveHostsFiles.hasOwnProperty(details.assetKey) === false || - this.liveHostsFiles[details.assetKey].off === true + this.liveHostsFiles[details.assetKey].off !== true ) { - return false; + return true; } return; }