Skip to content

Commit 588c24b

Browse files
committed
MOBILE-1331 prefetch: Fix infinite spinners in prefetch all
1 parent 696c232 commit 588c24b

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

www/core/lib/filepool.js

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1997,19 +1997,26 @@ angular.module('mm.core')
19971997
}, function() {
19981998
return undefined; // No previous status.
19991999
}).then(function(previousStatus) {
2000-
return db.insert(mmFilepoolPackagesStore, {
2001-
id: packageId,
2002-
component: component,
2003-
componentId: componentId,
2004-
status: status,
2005-
previous: previousStatus,
2006-
revision: revision,
2007-
timemodified: timemodified,
2008-
updated: new Date().getTime()
2009-
}).then(function(result) {
2000+
var promise;
2001+
if (previousStatus === status) {
2002+
// The package already has this status, no need to change it.
2003+
promise = $q.when();
2004+
} else {
2005+
promise = db.insert(mmFilepoolPackagesStore, {
2006+
id: packageId,
2007+
component: component,
2008+
componentId: componentId,
2009+
status: status,
2010+
previous: previousStatus,
2011+
revision: revision,
2012+
timemodified: timemodified,
2013+
updated: new Date().getTime()
2014+
});
2015+
}
2016+
2017+
return promise.then(function() {
20102018
// Success inserting, trigger event.
20112019
self._triggerPackageStatusChanged(siteId, component, componentId, status);
2012-
return result;
20132020
});
20142021
});
20152022
});

0 commit comments

Comments
 (0)