diff --git a/ext/src/_locales/en/messages.json b/ext/src/_locales/en/messages.json index e300ace..c6ff262 100755 --- a/ext/src/_locales/en/messages.json +++ b/ext/src/_locales/en/messages.json @@ -24,6 +24,9 @@ , "optionsBridgeFoundStatusText": { "message": "Bridge found" } + , "optionsBridgeIssueStatusText": { + "message": "Bridge issue" + } , "optionsBridgeNotFoundStatusText": { "message": "Bridge not found. Try downloading and installing the latest version." } @@ -45,6 +48,9 @@ , "optionsBridgeCompatible": { "message": "COMPATIBLE" } + , "optionsBridgeMaybeCompatible": { + "message": "MAYBE COMPATIBLE" + } , "optionsBridgeIncompatible": { "message": "INCOMPATIBLE" } diff --git a/ext/src/lib/getBridgeInfo.js b/ext/src/lib/getBridgeInfo.js index 56b9043..a7434c3 100644 --- a/ext/src/lib/getBridgeInfo.js +++ b/ext/src/lib/getBridgeInfo.js @@ -14,24 +14,36 @@ export default async function getBridgeInfo () { } /** - * Compare installed bridge version to the version the - * extension was built alongside and is known to be - * compatible with. - * - * TODO: Determine compatibility with semver and enforce/notify - * user. + * If the target version is above 0.x.x range, API is stable + * and versions with minor or patch level changes should be + * compatible. */ - if (applicationVersion !== APPLICATION_VERSION) { + const isVersionCompatible = + semver.eq(applicationVersion, APPLICATION_VERSION) + || semver.diff(applicationVersion, APPLICATION_VERSION) !== "major" + && semver.major(APPLICATION_VERSION) !== 0; + + const isVersionExact = semver.eq(applicationVersion, APPLICATION_VERSION); + const isVersionOlder = semver.lt(applicationVersion, APPLICATION_VERSION); + const isVersionNewer = semver.gt(applicationVersion, APPLICATION_VERSION); + + // Print compatibility info to console + if (!isVersionCompatible) { console.error(`Expecting ${APPLICATION_NAME} v${APPLICATION_VERSION}, found v${applicationVersion}.` - , semver.lt(applicationVersion, APPLICATION_VERSION) + , isVersionOlder ? "Try updating the native app to the latest version." : "Try updating the extension to the latest version"); } return { - version: applicationVersion - , isVersionCompatible: applicationVersion === APPLICATION_VERSION - , isVersionOlder: semver.lt(applicationVersion, APPLICATION_VERSION) - , isVersionNewer: semver.gt(applicationVersion, APPLICATION_VERSION) + name: APPLICATION_NAME + , version: applicationVersion + , expectedVersion: APPLICATION_VERSION + + // Version info + , isVersionExact + , isVersionCompatible + , isVersionOlder + , isVersionNewer }; } diff --git a/ext/src/options/assets/icons8-cancel-120.png b/ext/src/options/assets/icons8-cancel-120.png index 5f9750b..2ea85bd 100644 Binary files a/ext/src/options/assets/icons8-cancel-120.png and b/ext/src/options/assets/icons8-cancel-120.png differ diff --git a/ext/src/options/assets/icons8-ok-120.png b/ext/src/options/assets/icons8-ok-120.png index 10b59df..4697af0 100644 Binary files a/ext/src/options/assets/icons8-ok-120.png and b/ext/src/options/assets/icons8-ok-120.png differ diff --git a/ext/src/options/assets/icons8-warn-120.png b/ext/src/options/assets/icons8-warn-120.png new file mode 100644 index 0000000..be903a3 Binary files /dev/null and b/ext/src/options/assets/icons8-warn-120.png differ diff --git a/ext/src/options/index.jsx b/ext/src/options/index.jsx index 3b9a096..2307225 100644 --- a/ext/src/options/index.jsx +++ b/ext/src/options/index.jsx @@ -180,18 +180,29 @@ class App extends Component { ? "bridge__info--found" : "bridge__info--not-found"}`; + const [ statusIcon, statusText ] = do { + if (!bridgeInfo) { + [ "assets/icons8-cancel-120.png" + , _("optionsBridgeNotFoundStatusText") ] + } else { + if (bridgeInfo.isVersionExact) { + [ "assets/icons8-ok-120.png" + , _("optionsBridgeFoundStatusText") ] + } else { + [ "assets/icons8-warn-120.png" + , _("optionsBridgeIssueStatusText") ] + } + } + }; +