ui: fire autoCheck async

This commit is contained in:
Aaron Greenspan
2021-01-20 13:21:53 -07:00
committed by Aiden McClelland
parent e96ef695a3
commit e482ccf7fd
3 changed files with 6 additions and 11 deletions

View File

@@ -2,8 +2,7 @@ import { Component, Input } from '@angular/core'
import { ModalController } from '@ionic/angular'
import { ServerModel } from 'src/app/models/server-model'
import { ApiService } from 'src/app/services/api/api.service'
import { LoaderService } from 'src/app/services/loader.service'
import { pauseFor } from 'src/app/util/misc.util'
import { ConfigService } from 'src/app/services/config.service'
@Component({
selector: 'os-welcome',
@@ -19,12 +18,15 @@ export class OSWelcomePage {
private readonly modalCtrl: ModalController,
private readonly apiService: ApiService,
private readonly serverModel: ServerModel,
private readonly config: ConfigService,
) { }
// autoCheckUpdates default must be false when upgrading to 0.2.8
async dismiss () {
this.apiService
.patchServerConfig('autoCheckUpdates', this.autoCheckUpdates)
.then(() => this.serverModel.update({ autoCheckUpdates: this.autoCheckUpdates }))
.then(() => this.apiService.acknowledgeOSWelcome(this.config.version))
.catch(console.error),
this.modalCtrl.dismiss({ autoCheckUpdates: this.autoCheckUpdates })

View File

@@ -23,7 +23,6 @@ export class StartupAlertsNotifier {
displayedWelcomeMessage = false
checkedForUpdates = false
welcomeSetAutoUpdateCheck = false
async handleSpecial (server: Readonly<S9Server>): Promise<void> {
this.handleOSWelcome(server)
@@ -44,17 +43,11 @@ export class StartupAlertsNotifier {
},
})
modal.onDidDismiss().then(res => {
this.welcomeSetAutoUpdateCheck = res.data.autoCheckUpdates
this.apiService.acknowledgeOSWelcome(this.config.version)
this.handleUpdateCheck(server)
})
await modal.present()
}
private async handleUpdateCheck (server: Readonly<S9Server>) {
if (this.displayedWelcomeMessage && !this.welcomeSetAutoUpdateCheck) return
if (!this.displayedWelcomeMessage && (!server.autoCheckUpdates || this.checkedForUpdates)) return
if (!server.autoCheckUpdates || this.checkedForUpdates) return
this.checkedForUpdates = true
if (this.osUpdateService.updateIsAvailable(server.versionInstalled, server.versionLatest)) {

View File

@@ -1,3 +1,3 @@
{
"useMocks": true
"useMocks": false
}