Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -747,16 +747,13 @@ function showLoadingIndicator(id) {
}

function getAppsToUpdate(options) {
options = options||{}; // excludeCustomApps
options = options || {}; // excludeCustomApps
let appsToUpdate = [];
device.appsInstalled.forEach(appInstalled => {
let app = appNameToApp(appInstalled.id);
appInstalled.canUpdate = false;
if (app.version &&
app.version != appInstalled.version &&
(!options.excludeCustomApps || app.custom===undefined)) {
appInstalled.canUpdate = isAppUpdateable(appInstalled, app) && (!options.excludeCustomApps || app.custom === undefined);
if (appInstalled.canUpdate) {
appsToUpdate.push(app);
appInstalled.canUpdate = true;
}
});
return appsToUpdate;
Expand Down
6 changes: 5 additions & 1 deletion js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ function getVersionInfo(appListing, appInstalled) {
versionText = clicky("v"+appListing.version);
} else {
versionText = (appInstalled.version ? (clicky("v"+appInstalled.version)) : "Unknown version");
if (appListing.version != appInstalled.version) {
if (isAppUpdateable(appInstalled, appListing)) {
if (appListing.version) {
versionText += ", latest "+clicky("v"+appListing.version);
canUpdate = true;
Expand All @@ -255,6 +255,10 @@ function getVersionInfo(appListing, appInstalled) {
}
}

function isAppUpdateable(appInstalled, appListing) {
return appInstalled.version && appListing.version && versionLess(appInstalled.version, appListing.version);
}

function versionLess(a,b) {
let v = x => x.split(/[v.]/).reduce((a,b,c)=>a+parseInt(b,10)/Math.pow(1000,c),0);
return v(a) < v(b);
Expand Down