Merge pull request #741 from mikeller/fix_version_for_chrome

Fix Chrome issues with SemVer RC version.
10.3.x-maintenance
Michael Keller 2017-11-25 16:23:45 +13:00 committed by GitHub
commit c6c848dd8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 8 deletions

View File

@ -80,7 +80,7 @@ chrome.app.runtime.onLaunched.addListener(startApplication);
chrome.runtime.onInstalled.addListener(function (details) {
if (details.reason == 'update') {
var previousVersionArr = details.previousVersion.split('.'),
currentVersionArr = chrome.runtime.getManifest().version.split('.');
currentVersionArr = getManifestVersion().split('.');
// only fire up notification sequence when one of the major version numbers changed
if (currentVersionArr[0] > previousVersionArr[0] || currentVersionArr[1] > previousVersionArr[1]) {
@ -91,7 +91,7 @@ chrome.runtime.onInstalled.addListener(function (details) {
priority: 0,
type: 'basic',
title: manifest.name,
message: chrome.i18n.getMessage('notifications_app_just_updated_to_version', [manifest.version]),
message: chrome.i18n.getMessage('notifications_app_just_updated_to_version', [getManifestVersion(manifest)]),
iconUrl: '/images/icon_128.png',
buttons: [{'title': chrome.i18n.getMessage('notifications_click_here_to_start_app')}]
};
@ -110,3 +110,16 @@ chrome.notifications.onButtonClicked.addListener(function (notificationId, butto
startApplication();
}
});
function getManifestVersion(manifest) {
if (!manifest) {
manifest = chrome.runtime.getManifest();
}
var version = manifest.version_name;
if (!version) {
version = manifest.version;
}
return version;
}

View File

@ -5,7 +5,7 @@
function configuration_backup(callback) {
var activeProfile = null;
var version = chrome.runtime.getManifest().version;
var version = getManifestVersion();
if (version.indexOf(".") === -1) {
version = version + ".0.0";

21
main.js
View File

@ -7,9 +7,9 @@ $(document).ready(function () {
// alternative - window.navigator.appVersion.match(/Chrome\/([0-9.]*)/)[1];
GUI.log('Running - OS: <strong>' + GUI.operating_system + '</strong>, ' +
'Chrome: <strong>' + window.navigator.appVersion.replace(/.*Chrome\/([0-9.]*).*/, "$1") + '</strong>, ' +
'Configurator: <strong>' + chrome.runtime.getManifest().version + '</strong>');
'Configurator: <strong>' + getManifestVersion() + '</strong>');
$('#logo .version').text(chrome.runtime.getManifest().version);
$('#logo .version').text(getManifestVersion());
updateStatusBarVersion();
updateTopBarVersion();
@ -378,7 +378,7 @@ $(document).ready(function () {
});
function notifyOutdatedVersion(version) {
if (semver.lt(chrome.runtime.getManifest().version, version)) {
if (semver.lt(getManifestVersion(), version)) {
GUI.log('You are using an old version of ' + chrome.runtime.getManifest().name + '. Version ' + version + ' is available online with possible improvements and fixes.');
}
}
@ -533,7 +533,7 @@ function getFirmwareVersion(firmwareVersion, firmwareId, hardwareId) {
}
function getConfiguratorVersion() {
return chrome.i18n.getMessage('versionLabelConfigurator') + ': ' + chrome.runtime.getManifest().version;
return chrome.i18n.getMessage('versionLabelConfigurator') + ': ' + getManifestVersion();
}
function updateTopBarVersion(firmwareVersion, firmwareId, hardwareId) {
@ -557,3 +557,16 @@ function updateStatusBarVersion(firmwareVersion, firmwareId, hardwareId) {
$('#status-bar .version').text(versionText);
}
function getManifestVersion(manifest) {
if (!manifest) {
manifest = chrome.runtime.getManifest();
}
var version = manifest.version_name;
if (!version) {
version = manifest.version;
}
return version;
}

View File

@ -1,7 +1,8 @@
{
"manifest_version": 2,
"minimum_chrome_version": "38",
"version": "10.0.0-RC2",
"version": "10.0.0",
"version_name": "10.0.0-RC2",
"author": "Betaflight Squad",
"name": "Betaflight - Configurator",
"short_name": "Betaflight",