feat: pass web app version to snjs application (#623)

* feat: store web version in local storage

* feat: pass web app version to snjs application when creating WebApplication

* refactor: pass version in application constructor, remove unnecessary method

* refactor: move global variables declarations to separate files to avoid declaring them in all places where they are used

* refactor: better way to use global variables

* chore: add comment

* chore: make global constants pascal case

* chore: version bump for snjs

* chore: yarn.lock with correct snjs version

* chore: bump snjs version
This commit is contained in:
Vardan Hakobyan
2021-09-06 10:36:57 +04:00
committed by GitHub
parent b7d10810a5
commit 041d437bd4
7 changed files with 30 additions and 25 deletions

View File

@@ -1,8 +1,5 @@
'use strict';
declare const __VERSION__: string;
declare const __WEB__: boolean;
import { SNLog } from '@standardnotes/snjs';
import angular from 'angular';
import { configRoutes } from './routes';
@@ -66,6 +63,7 @@ import { NotesOptionsPanelDirective } from './components/NotesOptionsPanel';
import { IconDirective } from './components/Icon';
import { NoteTagsContainerDirective } from './components/NoteTagsContainer';
import { PreferencesDirective } from './preferences';
import { AppVersion, IsWebPlatform } from '@/version';
function reloadHiddenFirefoxTab(): boolean {
/**
@@ -191,10 +189,10 @@ const startApplication: StartApplication = async function startApplication(
});
};
if (__WEB__) {
if (IsWebPlatform) {
startApplication(
(window as any)._default_sync_server,
new BrowserBridge(__VERSION__),
new BrowserBridge(AppVersion),
(window as any)._websocket_url,
);
} else {

View File

@@ -3,8 +3,8 @@ import { isDesktopApplication, isDev } from '@/utils';
import { storage, StorageKey } from './localStorage';
import Bugsnag from '@bugsnag/js';
import { WebCrypto } from '../crypto';
import { AppVersion } from '@/version';
declare const __VERSION__: string;
declare global {
interface Window {
// eslint-disable-next-line camelcase
@@ -50,7 +50,7 @@ export function startErrorReporting(): void {
Bugsnag.start({
apiKey: window._bugsnag_api_key,
appType: isDesktopApplication() ? 'desktop' : 'web',
appVersion: __VERSION__,
appVersion: AppVersion,
collectUserIp: false,
autoTrackSessions: false,
releaseStage: isDev ? 'development' : undefined,

View File

@@ -24,6 +24,7 @@ import { IOService } from '@/services/ioService';
import { NativeExtManager } from '@/services/nativeExtManager';
import { StatusManager } from '@/services/statusManager';
import { ThemeManager } from '@/services/themeManager';
import { AppVersion } from '@/version';
type WebServices = {
appState: AppState;
@@ -63,6 +64,7 @@ export class WebApplication extends SNApplication {
identifier,
[],
defaultSyncServerHost,
AppVersion
);
this.$compile = $compile;
this.scope = scope;

View File

@@ -1,4 +1,5 @@
import { Platform, platformFromString } from '@standardnotes/snjs';
import { IsDesktopPlatform, IsWebPlatform } from '@/version';
declare const process: {
env: {
@@ -160,16 +161,12 @@ export async function preventRefreshing(
}
}
/** Platform-detection functions */
declare const __WEB__: boolean;
declare const __DESKTOP__: boolean;
if (!__WEB__ && !__DESKTOP__) {
if (!IsWebPlatform && !IsDesktopPlatform) {
throw Error(
'Neither __WEB__ nor __DESKTOP__ is true. Check your configuration files.'
);
}
export function isDesktopApplication() {
return __DESKTOP__;
return IsDesktopPlatform;
}

View File

@@ -0,0 +1,8 @@
/** Declared in webpack config */
declare const __VERSION__: string;
declare const __DESKTOP__: boolean;
declare const __WEB__: boolean;
export const AppVersion = __VERSION__;
export const IsDesktopPlatform = __DESKTOP__;
export const IsWebPlatform = __WEB__;

View File

@@ -71,7 +71,7 @@
"@reach/checkbox": "^0.13.2",
"@reach/dialog": "^0.13.0",
"@standardnotes/sncrypto-web": "1.5.2",
"@standardnotes/snjs": "2.11.2",
"@standardnotes/snjs": "2.12.1",
"mobx": "^6.3.2",
"mobx-react-lite": "^3.2.0",
"preact": "^10.5.12"

View File

@@ -2023,7 +2023,7 @@
dependencies:
"@standardnotes/common" "^1.0.0"
"@standardnotes/common@1.1.0", "@standardnotes/common@^1.0.0":
"@standardnotes/common@1.1.0", "@standardnotes/common@^1.0.0", "@standardnotes/common@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@standardnotes/common/-/common-1.1.0.tgz#5ffb0a50f9947471e236bb66d097f153ad9a148f"
integrity sha512-Nm2IFWbMSfZDD7cnKtN+Gjic0f+PhPq/da/o4eOoUKg21VeOaQkTn+jlQKraKIs6Lmf+w9mmPNAgMc5o4hj7Lg==
@@ -2035,12 +2035,12 @@
dependencies:
"@standardnotes/auth" "^3.2.0"
"@standardnotes/features@1.4.0":
version "1.4.0"
resolved "https://registry.yarnpkg.com/@standardnotes/features/-/features-1.4.0.tgz#64f0149eb94bee8cb7e748ad2dc2f94f5c2932f3"
integrity sha512-PQEjDdFjJ+hvGz6rD6LATtlICxNr2YKKwht69qGlDqMPSXQaljrq9bocAdGKuy+YOu+aKFvrmRbezsBK9rRIdw==
"@standardnotes/features@1.6.0":
version "1.6.0"
resolved "https://registry.yarnpkg.com/@standardnotes/features/-/features-1.6.0.tgz#91317255bbad376670fd81fa445abc2d14fd43d9"
integrity sha512-0gN1UKpX0LZxOk7HlnLxbl7N8Drvyw36zRErFn3pSetUNQpr92Pd6qTTNNflBBtY2pwzqoP4XVB/2kZRJFAo8w==
dependencies:
"@standardnotes/common" "^1.0.0"
"@standardnotes/common" "^1.1.0"
"@standardnotes/settings@1.2.0":
version "1.2.0"
@@ -2060,15 +2060,15 @@
"@standardnotes/sncrypto-common" "^1.5.2"
libsodium-wrappers "^0.7.8"
"@standardnotes/snjs@2.11.2":
version "2.11.2"
resolved "https://registry.yarnpkg.com/@standardnotes/snjs/-/snjs-2.11.2.tgz#2ae172950316ee3aa7ad95d4fec4dc85d7ac1269"
integrity sha512-49NPflKrBcAkVcs7nGf7D/oatcPRPZz7+TKyi4s9Xsxf69EmHIQhVu9u+sCUCaUTq2j1sjQt9tyCacjche7p4w==
"@standardnotes/snjs@2.12.1":
version "2.12.1"
resolved "https://registry.yarnpkg.com/@standardnotes/snjs/-/snjs-2.12.1.tgz#4c2cac0e9f87d55d7d24a30f0fbe90d878869c7b"
integrity sha512-4ehV9Nviko0yLs8NUToSXQvOTcQs4XlU2e1sfSkvZZ+Z+iQZo/gR/Xc9gXhr/PvJpahecJIAnbcLpPlJ/DU9MQ==
dependencies:
"@standardnotes/auth" "3.1.1"
"@standardnotes/common" "1.1.0"
"@standardnotes/domain-events" "2.0.0"
"@standardnotes/features" "1.4.0"
"@standardnotes/features" "1.6.0"
"@standardnotes/settings" "1.2.0"
"@standardnotes/sncrypto-common" "1.5.2"