send id to marketplace

This commit is contained in:
Matt Hill
2022-02-25 18:38:31 -07:00
committed by Aiden McClelland
parent 184381b536
commit 840fa8d49b
7 changed files with 34 additions and 23 deletions

View File

@@ -283,8 +283,8 @@ export class AppComponent {
if ( if (
ret.data.highScore && ret.data.highScore &&
(ret.data.highScore > (ret.data.highScore >
this.patch.data.ui.gaming?.snake?.['high-score'] || this.patch.getData().ui.gaming?.snake?.['high-score'] ||
!this.patch.data.ui.gaming?.snake?.['high-score']) !this.patch.getData().ui.gaming?.snake?.['high-score'])
) { ) {
const loader = await this.loadingCtrl.create({ const loader = await this.loadingCtrl.create({
spinner: 'lines', spinner: 'lines',
@@ -331,13 +331,11 @@ export class AppComponent {
break break
case ConnectionFailure.Tor: case ConnectionFailure.Tor:
message = 'Browser unable to connect over Tor.' message = 'Browser unable to connect over Tor.'
link = link = 'https://start9.com/latest/support/common-issues'
'https://start9.com/latest/support/common-issues'
break break
case ConnectionFailure.Lan: case ConnectionFailure.Lan:
message = 'Embassy not found on Local Area Network.' message = 'Embassy not found on Local Area Network.'
link = link = 'https://start9.com/latest/support/common-issues'
'https://start9.com/latest/support/common-issues'
break break
} }
await this.presentToastOffline(message, link) await this.presentToastOffline(message, link)

View File

@@ -36,8 +36,8 @@ export class SnakePage {
) {} ) {}
ngOnInit() { ngOnInit() {
if (this.patch.data.ui.gaming?.snake?.['high-score']) { if (this.patch.getData().ui.gaming?.snake?.['high-score']) {
this.highScore = this.patch.data.ui.gaming?.snake?.['high-score'] this.highScore = this.patch.getData().ui.gaming?.snake?.['high-score']
} }
} }

View File

@@ -49,7 +49,9 @@ export class MarketplaceService {
async load(): Promise<void> { async load(): Promise<void> {
try { try {
const [data, pkgs] = await Promise.all([ 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.getMarketplacePkgs({ page: 1, 'per-page': 100 }),
]) ])
this.data = data this.data = data

View File

@@ -90,7 +90,7 @@ export class MarketplacesPage {
async presentAction(id: string) { async presentAction(id: string) {
// no need to view actions if is selected marketplace // 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[] = [ const buttons: ActionSheetButton[] = [
{ {
@@ -125,7 +125,7 @@ export class MarketplacesPage {
private async connect(id: string): Promise<void> { private async connect(id: string): Promise<void> {
const marketplace: UIMarketplaceData = JSON.parse( const marketplace: UIMarketplaceData = JSON.parse(
JSON.stringify(this.patch.data.ui.marketplace), JSON.stringify(this.patch.getData().ui.marketplace),
) )
const url = id const url = id
@@ -140,7 +140,10 @@ export class MarketplacesPage {
await loader.present() await loader.present()
try { try {
await this.marketplaceService.getMarketplaceData({}, url) await this.marketplaceService.getMarketplaceData(
{ 'server-id': this.patch.getData()['server-info'].id },
url,
)
} catch (e) { } catch (e) {
this.errToast.present(e) this.errToast.present(e)
loader.dismiss() loader.dismiss()
@@ -171,7 +174,7 @@ export class MarketplacesPage {
private async delete(id: string): Promise<void> { private async delete(id: string): Promise<void> {
if (!id) return if (!id) return
const marketplace: UIMarketplaceData = JSON.parse( 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({ const loader = await this.loadingCtrl.create({
@@ -192,9 +195,9 @@ export class MarketplacesPage {
} }
private async save(url: string): Promise<void> { private async save(url: string): Promise<void> {
const marketplace = this.patch.data.ui.marketplace const marketplace = this.patch.getData().ui.marketplace
? (JSON.parse( ? (JSON.parse(
JSON.stringify(this.patch.data.ui.marketplace), JSON.stringify(this.patch.getData().ui.marketplace),
) as UIMarketplaceData) ) as UIMarketplaceData)
: { 'selected-id': undefined, 'known-hosts': {} } : { 'selected-id': undefined, 'known-hosts': {} }
@@ -212,7 +215,10 @@ export class MarketplacesPage {
try { try {
const id = v4() 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['known-hosts'][id] = { name, url }
} catch (e) { } catch (e) {
this.errToast.present(e) this.errToast.present(e)
@@ -232,9 +238,11 @@ export class MarketplacesPage {
} }
private async saveAndConnect(url: string): Promise<void> { private async saveAndConnect(url: string): Promise<void> {
const marketplace = this.patch.data.ui.marketplace await this.save(url)
const marketplace = this.patch.getData().ui.marketplace
? (JSON.parse( ? (JSON.parse(
JSON.stringify(this.patch.data.ui.marketplace), JSON.stringify(this.patch.getData().ui.marketplace),
) as UIMarketplaceData) ) as UIMarketplaceData)
: { 'selected-id': undefined, 'known-hosts': {} } : { 'selected-id': undefined, 'known-hosts': {} }
@@ -251,7 +259,10 @@ export class MarketplacesPage {
try { try {
const id = v4() 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['known-hosts'][id] = { name, url }
marketplace['selected-id'] = id marketplace['selected-id'] = id
} catch (e) { } catch (e) {
@@ -270,7 +281,7 @@ export class MarketplacesPage {
return return
} }
loader.message = 'Syncing store...' loader.message = 'Syncing marketplace data...'
try { try {
await this.marketplaceService.load() await this.marketplaceService.load()

View File

@@ -121,7 +121,7 @@ export class ServerShowPage {
} }
async presentAlertSystemRebuild() { 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({ const alert = await this.alertCtrl.create({
header: 'System Rebuild', header: 'System Rebuild',
message: new IonicSafeString( message: new IonicSafeString(

View File

@@ -242,7 +242,7 @@ export module RR {
// marketplace // marketplace
export type GetMarketplaceDataReq = { url?: string } export type GetMarketplaceDataReq = { 'server-id': string }
export type GetMarketplaceDataRes = MarketplaceData export type GetMarketplaceDataRes = MarketplaceData
export type GetMarketplaceEOSReq = { export type GetMarketplaceEOSReq = {

View File

@@ -26,7 +26,7 @@ export class EOSService {
const updateAvailable = const updateAvailable =
this.emver.compare( this.emver.compare(
this.eos.version, this.eos.version,
this.patch.data['server-info'].version, this.patch.getData()['server-info'].version,
) === 1 ) === 1
this.updateAvailable$.next(updateAvailable) this.updateAvailable$.next(updateAvailable)
return updateAvailable return updateAvailable