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__;