From 840fa8d49b06b7b34de021857097b49bb47faf63 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Fri, 25 Feb 2022 18:38:31 -0700 Subject: [PATCH] send id to marketplace --- frontend/projects/ui/src/app/app.component.ts | 10 +++--- .../ui/src/app/modals/snake/snake.page.ts | 4 +-- .../marketplace-routes/marketplace.service.ts | 4 ++- .../marketplaces/marketplaces.page.ts | 33 ++++++++++++------- .../server-show/server-show.page.ts | 2 +- .../ui/src/app/services/api/api.types.ts | 2 +- .../ui/src/app/services/eos.service.ts | 2 +- 7 files changed, 34 insertions(+), 23 deletions(-) diff --git a/frontend/projects/ui/src/app/app.component.ts b/frontend/projects/ui/src/app/app.component.ts index 91d3dc327..8b4eeaf1e 100644 --- a/frontend/projects/ui/src/app/app.component.ts +++ b/frontend/projects/ui/src/app/app.component.ts @@ -283,8 +283,8 @@ export class AppComponent { if ( ret.data.highScore && (ret.data.highScore > - this.patch.data.ui.gaming?.snake?.['high-score'] || - !this.patch.data.ui.gaming?.snake?.['high-score']) + this.patch.getData().ui.gaming?.snake?.['high-score'] || + !this.patch.getData().ui.gaming?.snake?.['high-score']) ) { const loader = await this.loadingCtrl.create({ spinner: 'lines', @@ -331,13 +331,11 @@ export class AppComponent { break case ConnectionFailure.Tor: message = 'Browser unable to connect over Tor.' - link = - 'https://start9.com/latest/support/common-issues' + link = 'https://start9.com/latest/support/common-issues' break case ConnectionFailure.Lan: message = 'Embassy not found on Local Area Network.' - link = - 'https://start9.com/latest/support/common-issues' + link = 'https://start9.com/latest/support/common-issues' break } await this.presentToastOffline(message, link) diff --git a/frontend/projects/ui/src/app/modals/snake/snake.page.ts b/frontend/projects/ui/src/app/modals/snake/snake.page.ts index 21c93ea4a..07b1d2650 100644 --- a/frontend/projects/ui/src/app/modals/snake/snake.page.ts +++ b/frontend/projects/ui/src/app/modals/snake/snake.page.ts @@ -36,8 +36,8 @@ export class SnakePage { ) {} ngOnInit() { - if (this.patch.data.ui.gaming?.snake?.['high-score']) { - this.highScore = this.patch.data.ui.gaming?.snake?.['high-score'] + if (this.patch.getData().ui.gaming?.snake?.['high-score']) { + this.highScore = this.patch.getData().ui.gaming?.snake?.['high-score'] } } diff --git a/frontend/projects/ui/src/app/pages/marketplace-routes/marketplace.service.ts b/frontend/projects/ui/src/app/pages/marketplace-routes/marketplace.service.ts index 18e198118..f86f8d471 100644 --- a/frontend/projects/ui/src/app/pages/marketplace-routes/marketplace.service.ts +++ b/frontend/projects/ui/src/app/pages/marketplace-routes/marketplace.service.ts @@ -49,7 +49,9 @@ export class MarketplaceService { async load(): Promise { try { const [data, pkgs] = await Promise.all([ - this.getMarketplaceData({}), + this.getMarketplaceData({ + 'server-id': this.patch.getData()['server-info'].id, + }), this.getMarketplacePkgs({ page: 1, 'per-page': 100 }), ]) this.data = data diff --git a/frontend/projects/ui/src/app/pages/server-routes/marketplaces/marketplaces.page.ts b/frontend/projects/ui/src/app/pages/server-routes/marketplaces/marketplaces.page.ts index aef0b4831..2569ac309 100644 --- a/frontend/projects/ui/src/app/pages/server-routes/marketplaces/marketplaces.page.ts +++ b/frontend/projects/ui/src/app/pages/server-routes/marketplaces/marketplaces.page.ts @@ -90,7 +90,7 @@ export class MarketplacesPage { async presentAction(id: string) { // no need to view actions if is selected marketplace - if (id === this.patch.data.ui.marketplace['selected-id']) return + if (id === this.patch.getData().ui.marketplace['selected-id']) return const buttons: ActionSheetButton[] = [ { @@ -125,7 +125,7 @@ export class MarketplacesPage { private async connect(id: string): Promise { const marketplace: UIMarketplaceData = JSON.parse( - JSON.stringify(this.patch.data.ui.marketplace), + JSON.stringify(this.patch.getData().ui.marketplace), ) const url = id @@ -140,7 +140,10 @@ export class MarketplacesPage { await loader.present() try { - await this.marketplaceService.getMarketplaceData({}, url) + await this.marketplaceService.getMarketplaceData( + { 'server-id': this.patch.getData()['server-info'].id }, + url, + ) } catch (e) { this.errToast.present(e) loader.dismiss() @@ -171,7 +174,7 @@ export class MarketplacesPage { private async delete(id: string): Promise { if (!id) return const marketplace: UIMarketplaceData = JSON.parse( - JSON.stringify(this.patch.data.ui.marketplace), + JSON.stringify(this.patch.getData().ui.marketplace), ) const loader = await this.loadingCtrl.create({ @@ -192,9 +195,9 @@ export class MarketplacesPage { } private async save(url: string): Promise { - const marketplace = this.patch.data.ui.marketplace + const marketplace = this.patch.getData().ui.marketplace ? (JSON.parse( - JSON.stringify(this.patch.data.ui.marketplace), + JSON.stringify(this.patch.getData().ui.marketplace), ) as UIMarketplaceData) : { 'selected-id': undefined, 'known-hosts': {} } @@ -212,7 +215,10 @@ export class MarketplacesPage { try { const id = v4() - const { name } = await this.marketplaceService.getMarketplaceData({}, url) + const { name } = await this.marketplaceService.getMarketplaceData( + { 'server-id': this.patch.getData()['server-info'].id }, + url, + ) marketplace['known-hosts'][id] = { name, url } } catch (e) { this.errToast.present(e) @@ -232,9 +238,11 @@ export class MarketplacesPage { } private async saveAndConnect(url: string): Promise { - const marketplace = this.patch.data.ui.marketplace + await this.save(url) + + const marketplace = this.patch.getData().ui.marketplace ? (JSON.parse( - JSON.stringify(this.patch.data.ui.marketplace), + JSON.stringify(this.patch.getData().ui.marketplace), ) as UIMarketplaceData) : { 'selected-id': undefined, 'known-hosts': {} } @@ -251,7 +259,10 @@ export class MarketplacesPage { try { const id = v4() - const { name } = await this.marketplaceService.getMarketplaceData({}, url) + const { name } = await this.marketplaceService.getMarketplaceData( + { 'server-id': this.patch.getData()['server-info'].id }, + url, + ) marketplace['known-hosts'][id] = { name, url } marketplace['selected-id'] = id } catch (e) { @@ -270,7 +281,7 @@ export class MarketplacesPage { return } - loader.message = 'Syncing store...' + loader.message = 'Syncing marketplace data...' try { await this.marketplaceService.load() diff --git a/frontend/projects/ui/src/app/pages/server-routes/server-show/server-show.page.ts b/frontend/projects/ui/src/app/pages/server-routes/server-show/server-show.page.ts index bf4ef89e0..df401cdbf 100644 --- a/frontend/projects/ui/src/app/pages/server-routes/server-show/server-show.page.ts +++ b/frontend/projects/ui/src/app/pages/server-routes/server-show/server-show.page.ts @@ -121,7 +121,7 @@ export class ServerShowPage { } async presentAlertSystemRebuild() { - const minutes = Object.keys(this.patch.data['package-data']).length * 2 + const minutes = Object.keys(this.patch.getData()['package-data']).length * 2 const alert = await this.alertCtrl.create({ header: 'System Rebuild', message: new IonicSafeString( diff --git a/frontend/projects/ui/src/app/services/api/api.types.ts b/frontend/projects/ui/src/app/services/api/api.types.ts index aec4f2d4d..ff0b59f54 100644 --- a/frontend/projects/ui/src/app/services/api/api.types.ts +++ b/frontend/projects/ui/src/app/services/api/api.types.ts @@ -242,7 +242,7 @@ export module RR { // marketplace - export type GetMarketplaceDataReq = { url?: string } + export type GetMarketplaceDataReq = { 'server-id': string } export type GetMarketplaceDataRes = MarketplaceData export type GetMarketplaceEOSReq = { diff --git a/frontend/projects/ui/src/app/services/eos.service.ts b/frontend/projects/ui/src/app/services/eos.service.ts index 1dfde300d..e4bac77ea 100644 --- a/frontend/projects/ui/src/app/services/eos.service.ts +++ b/frontend/projects/ui/src/app/services/eos.service.ts @@ -26,7 +26,7 @@ export class EOSService { const updateAvailable = this.emver.compare( this.eos.version, - this.patch.data['server-info'].version, + this.patch.getData()['server-info'].version, ) === 1 this.updateAvailable$.next(updateAvailable) return updateAvailable