mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-20 16:42:56 +00:00
fix: use stapps core version to compare with backends' core version
Note: not app version (e.g. 2.0.0). Closes #77
This commit is contained in:
@@ -19,6 +19,7 @@ import {StorageProvider} from '../storage/storage.provider';
|
||||
import {ConfigProvider, STORAGE_KEY_CONFIG} from './config.provider';
|
||||
import {ConfigFetchError, ConfigInitError, SavedConfigNotAvailable, WrongConfigVersionInStorage,} from './errors';
|
||||
import {NGXLogger} from "ngx-logger";
|
||||
import {dependencies} from '../../../../package.json';
|
||||
|
||||
describe('ConfigProvider', () => {
|
||||
let configProvider: ConfigProvider;
|
||||
@@ -122,7 +123,7 @@ describe('ConfigProvider', () => {
|
||||
} catch (err) {
|
||||
error = err;
|
||||
}
|
||||
expect(error).toEqual(new WrongConfigVersionInStorage('2.0.0', '0.1.0'));
|
||||
expect(error).toEqual(new WrongConfigVersionInStorage(scVersion, '0.1.0'));
|
||||
});
|
||||
|
||||
it('should throw error on saved app configuration not available', async () => {
|
||||
@@ -162,6 +163,8 @@ describe('ConfigProvider', () => {
|
||||
});
|
||||
});
|
||||
|
||||
const scVersion = dependencies["@openstapps/core"];
|
||||
|
||||
const sampleIndexResponse: SCIndexResponse = {
|
||||
app: {
|
||||
campusPolygon: {
|
||||
@@ -230,7 +233,7 @@ const sampleIndexResponse: SCIndexResponse = {
|
||||
],
|
||||
},
|
||||
backend: {
|
||||
SCVersion: '2.0.0',
|
||||
SCVersion: scVersion,
|
||||
externalRequestTimeout: 5000,
|
||||
hiddenTypes: [
|
||||
SCThingType.DateSeries,
|
||||
|
||||
@@ -16,6 +16,7 @@ import {Injectable} from '@angular/core';
|
||||
import {Client} from '@openstapps/api/lib/client';
|
||||
import {SCAppConfiguration, SCIndexResponse} from '@openstapps/core';
|
||||
import {NGXLogger} from 'ngx-logger';
|
||||
import {dependencies} from '../../../../package.json';
|
||||
import {environment} from '../../../environments/environment';
|
||||
import {StAppsWebHttpClient} from '../data/stapps-web-http-client.provider';
|
||||
import {StorageProvider} from '../storage/storage.provider';
|
||||
@@ -52,6 +53,11 @@ export class ConfigProvider {
|
||||
*/
|
||||
initialised = false;
|
||||
|
||||
/**
|
||||
* Version of the @openstapps/core package that app is using
|
||||
*/
|
||||
scVersion = dependencies['@openstapps/core'];
|
||||
|
||||
/**
|
||||
* Constructor, initialise api client
|
||||
*
|
||||
@@ -70,7 +76,7 @@ export class ConfigProvider {
|
||||
*/
|
||||
async fetch(): Promise<SCIndexResponse> {
|
||||
try {
|
||||
return await this.client.handshake(environment.backend_version);
|
||||
return await this.client.handshake(this.scVersion);
|
||||
} catch (error) {
|
||||
throw new ConfigFetchError();
|
||||
}
|
||||
@@ -113,8 +119,8 @@ export class ConfigProvider {
|
||||
this.config = await this.loadLocal();
|
||||
this.initialised = true;
|
||||
this.logger.log(`initialised configuration from storage`);
|
||||
if (this.config.backend.SCVersion !== environment.backend_version) {
|
||||
loadError = new WrongConfigVersionInStorage(environment.backend_version, this.config.backend.SCVersion);
|
||||
if (this.config.backend.SCVersion !== this.scVersion) {
|
||||
loadError = new WrongConfigVersionInStorage(this.scVersion, this.config.backend.SCVersion);
|
||||
this.logger.warn(loadError);
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user