From c680a3b830c4a6c052c0205696318afc176f0f45 Mon Sep 17 00:00:00 2001 From: Drew Ansbacher Date: Thu, 8 Jul 2021 10:54:49 -0600 Subject: [PATCH] remove not needed subs --- ui/src/app/guards/maintenance.guard.ts | 11 +-- .../app-actions/app-actions.page.html | 2 +- .../app-actions/app-actions.page.ts | 15 ++-- .../app-interfaces/app-interfaces.page.html | 2 +- .../app-interfaces/app-interfaces.page.ts | 13 +--- .../apps-routes/app-list/app-list.page.html | 71 ++++++++++--------- .../apps-routes/app-list/app-list.page.ts | 4 -- .../app-restore/app-restore.page.ts | 14 +--- .../pages/maintenance/maintenance.page.html | 2 +- .../marketplace-list.page.html | 41 +---------- .../marketplace-list/marketplace-list.page.ts | 5 -- .../marketplace-show/marketplace-show.page.ts | 1 - .../dev-options/dev-options.page.html | 2 +- .../dev-options/dev-options.page.ts | 16 +---- .../preferences/preferences.page.html | 8 +-- .../preferences/preferences.page.ts | 17 +---- .../server-specs/server-specs.page.html | 2 +- .../server-specs/server-specs.page.ts | 17 +---- .../pages/server-routes/wifi/wifi.page.html | 2 +- .../app/pages/server-routes/wifi/wifi.page.ts | 16 +---- ui/src/app/services/connection.service.ts | 16 +---- .../app/services/patch-db/patch-db.service.ts | 1 + ui/ui-config.json | 2 +- 23 files changed, 65 insertions(+), 215 deletions(-) diff --git a/ui/src/app/guards/maintenance.guard.ts b/ui/src/app/guards/maintenance.guard.ts index dd2b58b0a..4368cc304 100644 --- a/ui/src/app/guards/maintenance.guard.ts +++ b/ui/src/app/guards/maintenance.guard.ts @@ -8,17 +8,10 @@ import { PatchDbModel } from '../services/patch-db/patch-db.service' providedIn: 'root', }) export class MaintenanceGuard implements CanActivate, CanActivateChild { - serverStatus: ServerStatus - constructor ( private readonly router: Router, private readonly patch: PatchDbModel, - ) { - this.patch.watch$('server-info', 'status') - .pipe( - tap(status => this.serverStatus = status), - ).subscribe() - } + ) { } canActivate (): boolean { return this.runServerStatusCheck() @@ -29,7 +22,7 @@ export class MaintenanceGuard implements CanActivate, CanActivateChild { } private runServerStatusCheck (): boolean { - if ([ServerStatus.Updating, ServerStatus.BackingUp].includes(this.serverStatus)) { + if ([ServerStatus.Updating, ServerStatus.BackingUp].includes(this.patch.data['server-info']?.status)) { this.router.navigate(['/maintenance'], { replaceUrl: true }) return false } else { diff --git a/ui/src/app/pages/apps-routes/app-actions/app-actions.page.html b/ui/src/app/pages/apps-routes/app-actions/app-actions.page.html index 5904df987..c118e708b 100644 --- a/ui/src/app/pages/apps-routes/app-actions/app-actions.page.html +++ b/ui/src/app/pages/apps-routes/app-actions/app-actions.page.html @@ -8,7 +8,7 @@ - + diff --git a/ui/src/app/pages/apps-routes/app-actions/app-actions.page.ts b/ui/src/app/pages/apps-routes/app-actions/app-actions.page.ts index c9d9aa775..80e8c51bf 100644 --- a/ui/src/app/pages/apps-routes/app-actions/app-actions.page.ts +++ b/ui/src/app/pages/apps-routes/app-actions/app-actions.page.ts @@ -16,11 +16,11 @@ import { Subscription } from 'rxjs' styleUrls: ['./app-actions.page.scss'], }) export class AppActionsPage { - installed: InstalledPackageDataEntry - subs: Subscription[] = [] @ViewChild(IonContent) content: IonContent + pkgId: string + constructor ( private readonly route: ActivatedRoute, private readonly apiService: ApiService, @@ -29,18 +29,11 @@ export class AppActionsPage { private readonly loaderService: LoaderService, private readonly wizardBaker: WizardBaker, private readonly navCtrl: NavController, - private readonly patch: PatchDbModel, + public readonly patch: PatchDbModel, ) { } ngOnInit () { - const pkgId = this.route.snapshot.paramMap.get('pkgId') - - this.subs = [ - this.patch.watch$('package-data', pkgId, 'installed') - .subscribe(installed => { - this.installed = installed - }), - ] + this.pkgId = this.route.snapshot.paramMap.get('pkgId') } ngAfterViewInit () { diff --git a/ui/src/app/pages/apps-routes/app-interfaces/app-interfaces.page.html b/ui/src/app/pages/apps-routes/app-interfaces/app-interfaces.page.html index a98d84ab4..74502338d 100644 --- a/ui/src/app/pages/apps-routes/app-interfaces/app-interfaces.page.html +++ b/ui/src/app/pages/apps-routes/app-interfaces/app-interfaces.page.html @@ -8,7 +8,7 @@ - + diff --git a/ui/src/app/pages/apps-routes/app-interfaces/app-interfaces.page.ts b/ui/src/app/pages/apps-routes/app-interfaces/app-interfaces.page.ts index 185a3354a..e0b20a9bd 100644 --- a/ui/src/app/pages/apps-routes/app-interfaces/app-interfaces.page.ts +++ b/ui/src/app/pages/apps-routes/app-interfaces/app-interfaces.page.ts @@ -16,30 +16,23 @@ export class AppInterfacesPage { pkg: PackageDataEntry @ViewChild(IonContent) content: IonContent - subs: Subscription[] = [] + pkgId: string constructor ( private readonly route: ActivatedRoute, private readonly toastCtrl: ToastController, private readonly config: ConfigService, - private readonly patch: PatchDbModel, + public readonly patch: PatchDbModel, ) { } ngOnInit () { - const pkgId = this.route.snapshot.paramMap.get('pkgId') - this.subs = [ - this.patch.watch$('package-data', pkgId).subscribe(pkg => this.pkg = pkg), - ] + this.pkgId = this.route.snapshot.paramMap.get('pkgId') } ngAfterViewInit () { this.content.scrollToPoint(undefined, 1) } - ngOnDestroy () { - this.subs.forEach(sub => sub.unsubscribe()) - } - async copy (address: string): Promise { let message = '' await copyToClipboard(address || '') diff --git a/ui/src/app/pages/apps-routes/app-list/app-list.page.html b/ui/src/app/pages/apps-routes/app-list/app-list.page.html index 4ca0edc51..4286f990c 100644 --- a/ui/src/app/pages/apps-routes/app-list/app-list.page.html +++ b/ui/src/app/pages/apps-routes/app-list/app-list.page.html @@ -8,43 +8,44 @@ - -
-
-

Welcome to your Embassy

-

Get started by installing your first service.

+
+
+
+

Welcome to your Embassy

+

Get started by installing your first service.

+
+ + + Marketplace +
- - - Marketplace - -
- - - - - -
-
- + + + + + +
+
+ +
-
- - icon - - - - - + + icon + + + + + - - - {{ (pkg.value | manifest).title }} - - - - - - + + + {{ (pkg.value | manifest).title }} + + + + + + +
diff --git a/ui/src/app/pages/apps-routes/app-list/app-list.page.ts b/ui/src/app/pages/apps-routes/app-list/app-list.page.ts index 4a07daa12..2b47dc031 100644 --- a/ui/src/app/pages/apps-routes/app-list/app-list.page.ts +++ b/ui/src/app/pages/apps-routes/app-list/app-list.page.ts @@ -11,7 +11,6 @@ import { Subscription } from 'rxjs' styleUrls: ['./app-list.page.scss'], }) export class AppListPage { - pkgs: { [id: string]: PackageDataEntry } = { } connected: boolean subs: Subscription[] = [] @@ -23,9 +22,6 @@ export class AppListPage { ngOnInit () { this.subs = [ - this.patch.watch$('package-data').subscribe(pkgs => { - this.pkgs = pkgs - }), this.patch.connected$().subscribe(c => this.connected = c), ] } diff --git a/ui/src/app/pages/apps-routes/app-restore/app-restore.page.ts b/ui/src/app/pages/apps-routes/app-restore/app-restore.page.ts index c675f29cd..35ec75e88 100644 --- a/ui/src/app/pages/apps-routes/app-restore/app-restore.page.ts +++ b/ui/src/app/pages/apps-routes/app-restore/app-restore.page.ts @@ -2,7 +2,7 @@ import { Component, ViewChild } from '@angular/core' import { IonContent, LoadingController, ModalController } from '@ionic/angular' import { ApiService } from 'src/app/services/api/api.service' import { BackupConfirmationComponent } from 'src/app/modals/backup-confirmation/backup-confirmation.component' -import { DiskInfo, PartitionInfoEntry } from 'src/app/services/api/api-types' +import { DiskInfo } from 'src/app/services/api/api-types' import { ActivatedRoute } from '@angular/router' import { PatchDbModel } from 'src/app/services/patch-db/patch-db.service' import { Subscription } from 'rxjs' @@ -33,13 +33,7 @@ export class AppRestorePage { ngOnInit () { this.pkgId = this.route.snapshot.paramMap.get('pkgId') - - this.subs = [ - this.patch.watch$('package-data', this.pkgId, 'installed', 'manifest', 'title') - .subscribe(title => { - this.title = title - }), - ] + this.title = this.patch.data['package-data'][this.pkgId].installed.manifest.title this.getExternalDisks() } @@ -48,10 +42,6 @@ export class AppRestorePage { this.content.scrollToPoint(undefined, 1) } - ngOnDestroy () { - this.subs.forEach(sub => sub.unsubscribe()) - } - async refresh () { this.loading = true await this.getExternalDisks() diff --git a/ui/src/app/pages/maintenance/maintenance.page.html b/ui/src/app/pages/maintenance/maintenance.page.html index f7a895e88..f9717e20d 100644 --- a/ui/src/app/pages/maintenance/maintenance.page.html +++ b/ui/src/app/pages/maintenance/maintenance.page.html @@ -1,4 +1,4 @@ - + diff --git a/ui/src/app/pages/marketplace-routes/marketplace-list/marketplace-list.page.html b/ui/src/app/pages/marketplace-routes/marketplace-list/marketplace-list.page.html index 6fa53c03e..00146a8fe 100644 --- a/ui/src/app/pages/marketplace-routes/marketplace-list/marketplace-list.page.html +++ b/ui/src/app/pages/marketplace-routes/marketplace-list/marketplace-list.page.html @@ -58,7 +58,7 @@

{{ pkg.title }}

{{ pkg.descriptionShort }}

- +

Installed Update Available @@ -81,45 +81,6 @@ - - diff --git a/ui/src/app/pages/marketplace-routes/marketplace-list/marketplace-list.page.ts b/ui/src/app/pages/marketplace-routes/marketplace-list/marketplace-list.page.ts index 418c3fdc3..f980b2201 100644 --- a/ui/src/app/pages/marketplace-routes/marketplace-list/marketplace-list.page.ts +++ b/ui/src/app/pages/marketplace-routes/marketplace-list/marketplace-list.page.ts @@ -25,7 +25,6 @@ export class MarketplaceListPage { data: MarketplaceData eos: MarketplaceEOS pkgs: AvailablePreview[] = [] - installedPkgs: { [id: string]: PackageDataEntry } = { } PackageState = PackageState @@ -43,10 +42,6 @@ export class MarketplaceListPage { ) { } async ngOnInit () { - this.subs = [ - this.patch.watch$('package-data') - .subscribe(pkgs => this.installedPkgs = pkgs), - ] try { const [data, eos, pkgs] = await Promise.all([ diff --git a/ui/src/app/pages/marketplace-routes/marketplace-show/marketplace-show.page.ts b/ui/src/app/pages/marketplace-routes/marketplace-show/marketplace-show.page.ts index 9c2dead89..32f73abca 100644 --- a/ui/src/app/pages/marketplace-routes/marketplace-show/marketplace-show.page.ts +++ b/ui/src/app/pages/marketplace-routes/marketplace-show/marketplace-show.page.ts @@ -46,7 +46,6 @@ export class MarketplaceShowPage { this.subs = [ this.patch.watch$('package-data', this.pkgId) .subscribe(pkg => { - console.log(pkg) this.installedPkg = pkg }), ] diff --git a/ui/src/app/pages/server-routes/developer-routes/dev-options/dev-options.page.html b/ui/src/app/pages/server-routes/developer-routes/dev-options/dev-options.page.html index dac499972..0a473a3cb 100644 --- a/ui/src/app/pages/server-routes/developer-routes/dev-options/dev-options.page.html +++ b/ui/src/app/pages/server-routes/developer-routes/dev-options/dev-options.page.html @@ -7,7 +7,7 @@ - + diff --git a/ui/src/app/pages/server-routes/developer-routes/dev-options/dev-options.page.ts b/ui/src/app/pages/server-routes/developer-routes/dev-options/dev-options.page.ts index 09f4c3be6..ee41080a9 100644 --- a/ui/src/app/pages/server-routes/developer-routes/dev-options/dev-options.page.ts +++ b/ui/src/app/pages/server-routes/developer-routes/dev-options/dev-options.page.ts @@ -10,27 +10,13 @@ import { Subscription } from 'rxjs' styleUrls: ['./dev-options.page.scss'], }) export class DevOptionsPage { - server: ServerInfo = { } as any subs: Subscription[] = [] constructor ( private readonly serverConfigService: ServerConfigService, - private readonly patch: PatchDbModel, + public readonly patch: PatchDbModel, ) { } - ngOnInit () { - this.subs = [ - this.patch.watch$('server-info') - .subscribe(server => { - this.server = server - }), - ] - } - - ngOnDestroy () { - this.subs.forEach(sub => sub.unsubscribe()) - } - async presentModalValueEdit (key: string, current?: any): Promise { await this.serverConfigService.presentModalValueEdit(key, current) } diff --git a/ui/src/app/pages/server-routes/preferences/preferences.page.html b/ui/src/app/pages/server-routes/preferences/preferences.page.html index 8c193984b..b0745664d 100644 --- a/ui/src/app/pages/server-routes/preferences/preferences.page.html +++ b/ui/src/app/pages/server-routes/preferences/preferences.page.html @@ -10,14 +10,10 @@ - + Auto Check for Updates - {{ ui['auto-check-updates'] }} + {{ patch.data.ui['auto-check-updates'] }} - diff --git a/ui/src/app/pages/server-routes/preferences/preferences.page.ts b/ui/src/app/pages/server-routes/preferences/preferences.page.ts index 8b11e4550..968fa31d8 100644 --- a/ui/src/app/pages/server-routes/preferences/preferences.page.ts +++ b/ui/src/app/pages/server-routes/preferences/preferences.page.ts @@ -2,7 +2,6 @@ import { Component } from '@angular/core' import { ServerConfigService } from 'src/app/services/server-config.service' import { PatchDbModel } from 'src/app/services/patch-db/patch-db.service' import { Subscription } from 'rxjs' -import { UIData } from 'src/app/services/patch-db/data-model' @Component({ selector: 'preferences', @@ -11,26 +10,12 @@ import { UIData } from 'src/app/services/patch-db/data-model' }) export class PreferencesPage { subs: Subscription[] = [] - ui: UIData = { } as any constructor ( private readonly serverConfigService: ServerConfigService, - private readonly patch: PatchDbModel, + public readonly patch: PatchDbModel, ) { } - ngOnInit () { - this.subs = [ - this.patch.watch$('ui') - .subscribe(ui => { - this.ui = ui - }), - ] - } - - ngOnDestroy () { - this.subs.forEach(sub => sub.unsubscribe()) - } - async presentModalValueEdit (key: string, current?: string): Promise { await this.serverConfigService.presentModalValueEdit(key, current) } diff --git a/ui/src/app/pages/server-routes/server-specs/server-specs.page.html b/ui/src/app/pages/server-routes/server-specs/server-specs.page.html index 8340e728c..7246ce56b 100644 --- a/ui/src/app/pages/server-routes/server-specs/server-specs.page.html +++ b/ui/src/app/pages/server-routes/server-specs/server-specs.page.html @@ -11,7 +11,7 @@ Basic - +

Version

diff --git a/ui/src/app/pages/server-routes/server-specs/server-specs.page.ts b/ui/src/app/pages/server-routes/server-specs/server-specs.page.ts index 11b5c652c..487dcc90a 100644 --- a/ui/src/app/pages/server-routes/server-specs/server-specs.page.ts +++ b/ui/src/app/pages/server-routes/server-specs/server-specs.page.ts @@ -2,7 +2,6 @@ import { Component } from '@angular/core' import { ToastController } from '@ionic/angular' import { copyToClipboard } from 'src/app/util/web.util' import { PatchDbModel } from 'src/app/services/patch-db/patch-db.service' -import { ServerInfo } from 'src/app/services/patch-db/data-model' import { Subscription } from 'rxjs' @Component({ @@ -11,27 +10,13 @@ import { Subscription } from 'rxjs' styleUrls: ['./server-specs.page.scss'], }) export class ServerSpecsPage { - server: ServerInfo subs: Subscription[] = [] constructor ( private readonly toastCtrl: ToastController, - private readonly patch: PatchDbModel, + public readonly patch: PatchDbModel, ) { } - ngOnInit () { - this.subs = [ - this.patch.watch$('server-info') - .subscribe(server => { - this.server = server - }), - ] - } - - ngOnDestroy () { - this.subs.forEach(sub => sub.unsubscribe()) - } - async copy (address: string) { let message = '' await copyToClipboard(address || '') diff --git a/ui/src/app/pages/server-routes/wifi/wifi.page.html b/ui/src/app/pages/server-routes/wifi/wifi.page.html index cb10f4339..de3dce57c 100644 --- a/ui/src/app/pages/server-routes/wifi/wifi.page.html +++ b/ui/src/app/pages/server-routes/wifi/wifi.page.html @@ -26,7 +26,7 @@ Saved Networks - + {{ ssid }} Connected diff --git a/ui/src/app/pages/server-routes/wifi/wifi.page.ts b/ui/src/app/pages/server-routes/wifi/wifi.page.ts index 31a9830dd..c27f6c6e7 100644 --- a/ui/src/app/pages/server-routes/wifi/wifi.page.ts +++ b/ui/src/app/pages/server-routes/wifi/wifi.page.ts @@ -15,7 +15,6 @@ import { Subscription } from 'rxjs' }) export class WifiListPage { error = '' - wifi: WiFiInfo subs: Subscription[] = [] constructor ( @@ -23,22 +22,9 @@ export class WifiListPage { private readonly loader: LoaderService, private readonly actionCtrl: ActionSheetController, private readonly wifiService: WifiService, - private readonly patch: PatchDbModel, + public readonly patch: PatchDbModel, ) { } - ngOnInit () { - this.subs = [ - this.patch.watch$('server-info', 'wifi') - .subscribe(wifi => { - this.wifi = wifi - }), - ] - } - - ngOnDestroy () { - this.subs.forEach(sub => sub.unsubscribe()) - } - async presentAction (ssid: string, wifi: WiFiInfo) { const buttons: ActionSheetButton[] = [ { diff --git a/ui/src/app/services/connection.service.ts b/ui/src/app/services/connection.service.ts index a6a265b0e..4d5bbdf05 100644 --- a/ui/src/app/services/connection.service.ts +++ b/ui/src/app/services/connection.service.ts @@ -1,6 +1,5 @@ import { Injectable } from '@angular/core' import { BehaviorSubject, combineLatest, fromEvent, merge, Subscription } from 'rxjs' -import { DataModel } from './patch-db/data-model' import { ConnectionStatus, PatchDbModel } from './patch-db/patch-db.service' import { HttpService, Method } from './http.service' import { distinctUntilChanged } from 'rxjs/operators' @@ -9,7 +8,6 @@ import { distinctUntilChanged } from 'rxjs/operators' providedIn: 'root', }) export class ConnectionService { - private addrs: DataModel['server-info']['connection-addresses'] private readonly networkState$ = new BehaviorSubject(true) private readonly connectionFailure$ = new BehaviorSubject(ConnectionFailure.None) private subs: Subscription[] = [] @@ -25,15 +23,6 @@ export class ConnectionService { start () { this.subs = [ - this.patch.watch$('server-info') - .subscribe(data => { - if (!data) return - this.addrs = data['connection-addresses'] || { - tor: [], - clearnet: [], - } - }), - merge(fromEvent(window, 'online'), fromEvent(window, 'offline')) .subscribe(event => { this.networkState$.next(event.type === 'online') @@ -42,6 +31,7 @@ export class ConnectionService { combineLatest([this.networkState$.pipe(distinctUntilChanged()), this.patch.watchConnection$().pipe(distinctUntilChanged())]) .subscribe(async ([network, connectionStatus]) => { console.log('CONNECTION STATUS', connectionStatus) + const addrs = this.patch.data['server-info']?.['connection-addresses'] if (connectionStatus !== ConnectionStatus.Disconnected) { this.connectionFailure$.next(ConnectionFailure.None) } else if (!network) { @@ -49,12 +39,12 @@ export class ConnectionService { } else { console.log('diagnosing') this.connectionFailure$.next(ConnectionFailure.Diagnosing) - const torSuccess = await this.testAddrs(this.addrs.tor) + const torSuccess = await this.testAddrs(addrs?.tor || []) if (torSuccess) { console.log('TOR SUCCESS, EMBASSY IS PROBLEM') this.connectionFailure$.next(ConnectionFailure.Embassy) } else { - const clearnetSuccess = await this.testAddrs(this.addrs.clearnet) + const clearnetSuccess = await this.testAddrs(addrs?.clearnet || []) if (clearnetSuccess) { console.log('CLEARNET SUCCESS, TOR IS PROBLEM') this.connectionFailure$.next(ConnectionFailure.Tor) diff --git a/ui/src/app/services/patch-db/patch-db.service.ts b/ui/src/app/services/patch-db/patch-db.service.ts index b58af4ed7..6a7cea320 100644 --- a/ui/src/app/services/patch-db/patch-db.service.ts +++ b/ui/src/app/services/patch-db/patch-db.service.ts @@ -33,6 +33,7 @@ export class PatchDbModel { async init (): Promise { const cache = await this.bootstrapper.init() + console.log('CACHECACHE', cache) this.patchDb = new PatchDB([this.source, this.http], this.http, cache) this.sequence$ = this.patchDb.store.sequence$.asObservable() diff --git a/ui/ui-config.json b/ui/ui-config.json index 65a58f496..7f06abd3a 100644 --- a/ui/ui-config.json +++ b/ui/ui-config.json @@ -10,7 +10,7 @@ }, "mocks": { "enabled": true, - "connection": "ws", + "connection": "poll", "rpcPort": "5959", "wsPort": "5960", "maskAs": "tor",