Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Update notification - based on current platform #14655

Merged
merged 4 commits into from
Mar 5, 2019
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
23 changes: 1 addition & 22 deletions src/extensions/default/AutoUpdate/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,27 +329,6 @@ define(function (require, exports, module) {
}


/**
* Generates the extension for installer file, based on platform
* @returns {string} - OS - current OS }
*/
function getPlatformInfo() {
var OS = "";

if (/Windows|Win32|WOW64|Win64/.test(window.navigator.userAgent)) {
OS = "WIN";
} else if (/Mac/.test(window.navigator.userAgent)) {
OS = "OSX";
} else if (/Linux|X11/.test(window.navigator.userAgent)) {
OS = "LINUX32";
if (/x86_64/.test(window.navigator.appVersion + window.navigator.userAgent)) {
OS = "LINUX64";
}
}

return OS;
}

/**
* Initializes the state for AutoUpdate process
* @returns {$.Deferred} - a jquery promise,
Expand Down Expand Up @@ -466,7 +445,7 @@ define(function (require, exports, module) {
console.warn("AutoUpdate : updates information not available.");
return;
}
var OS = getPlatformInfo(),
var OS = brackets.getPlatformInfo(),
checksum,
downloadURL,
installerName,
Expand Down
18 changes: 18 additions & 0 deletions src/utils/Global.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,24 @@ define(function (require, exports, module) {
global.brackets.platform = "win";
}

// Expose platform info for build applicability consumption
global.brackets.getPlatformInfo = function () {
var OS = "";

if (/Windows|Win32|WOW64|Win64/.test(window.navigator.userAgent)) {
OS = "WIN";
} else if (/Mac/.test(window.navigator.userAgent)) {
OS = "OSX";
} else if (/Linux|X11/.test(window.navigator.userAgent)) {
OS = "LINUX32";
if (/x86_64/.test(window.navigator.appVersion + window.navigator.userAgent)) {
OS = "LINUX64";
}
}

return OS;
};

global.brackets.inBrowser = !global.brackets.hasOwnProperty("fs");

// Are we in a desktop shell with a native menu bar?
Expand Down
20 changes: 15 additions & 5 deletions src/utils/UpdateNotification.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,13 @@ define(function (require, exports, module) {
return result.promise();
}

/**
* Checks whether a build is applicable to the current platform.
*/
function _checkBuildApplicability(buildInfo) {
return !buildInfo.platforms || buildInfo.platforms[brackets.getPlatformInfo()];
}

/**
* Return a new array of version information that is newer than "buildNumber".
* Returns null if there is no new version information.
Expand All @@ -270,20 +277,23 @@ define(function (require, exports, module) {
// should get through the search quickly.
var lastIndex = 0;
var len = versionInfo.length;
var versionEntry;
var validBuildEntries;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you can initialize this to null


while (lastIndex < len) {
if (versionInfo[lastIndex].buildNumber <= buildNumber) {
versionEntry = versionInfo[lastIndex];
if (versionEntry.buildNumber <= buildNumber) {
break;
}
lastIndex++;
}

if (lastIndex > 0) {
return versionInfo.slice(0, lastIndex);
// Filter recent update entries based on applicability to current platform
validBuildEntries = versionInfo.slice(0, lastIndex).filter(_checkBuildApplicability);
}

// No new version info
return null;
return validBuildEntries;
}

/**
Expand Down Expand Up @@ -446,7 +456,7 @@ define(function (require, exports, module) {
return;
}

if (allUpdates) {
if (allUpdates && allUpdates.length > 0) {
// Always show the "update available" icon if any updates are available
var $updateNotification = $("#update-notification");

Expand Down