mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-04-01 04:53:40 +00:00
start adding welcome OS screen
This commit is contained in:
committed by
Aiden McClelland
parent
29d5e3b36e
commit
778d22ab2b
@@ -1,18 +1,27 @@
|
||||
import { Injectable } from '@angular/core'
|
||||
import { ToastController, NavController } from '@ionic/angular'
|
||||
import { ConfigService } from 'src/app/services/config.service'
|
||||
import { ToastController, NavController, ModalController } from '@ionic/angular'
|
||||
import { ServerModel, S9Server } from '../models/server-model'
|
||||
import { OSWelcomePage } from '../modals/os-welcome/os-welcome.page'
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class SyncNotifier {
|
||||
constructor (
|
||||
private readonly config: ConfigService,
|
||||
private readonly toastCtrl: ToastController,
|
||||
private readonly modalCtrl: ModalController,
|
||||
private readonly navCtrl: NavController,
|
||||
private readonly serverModel: ServerModel,
|
||||
) { }
|
||||
|
||||
async handleNotifications (server: Readonly<S9Server>): Promise<void> {
|
||||
async handleSpecial (server: Readonly<S9Server>): Promise<void> {
|
||||
this.handleNotifications(server)
|
||||
this.handleOSWelcome(server)
|
||||
}
|
||||
|
||||
private async handleNotifications (server: Readonly<S9Server>) {
|
||||
const count = server.notifications.length
|
||||
|
||||
if (!count) { return }
|
||||
@@ -47,4 +56,19 @@ export class SyncNotifier {
|
||||
await toast.present()
|
||||
this.serverModel.update(updates)
|
||||
}
|
||||
|
||||
private async handleOSWelcome(server: Readonly<S9Server>) {
|
||||
if (server.welcomeSeen || server.versionInstalled !== this.config.version) return
|
||||
|
||||
const modal = await this.modalCtrl.create({
|
||||
backdropDismiss: false,
|
||||
component: OSWelcomePage,
|
||||
presentingElement: await this.modalCtrl.getTop(),
|
||||
componentProps: {
|
||||
version: server.versionInstalled
|
||||
},
|
||||
})
|
||||
|
||||
await modal.present()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ export class SyncDaemon {
|
||||
stop () { this.$sync$.next(false) }
|
||||
sync (): Observable<void> {
|
||||
return from(this.getServerAndApps()).pipe(
|
||||
concatMap(() => this.syncNotifier.handleNotifications(this.serverModel.peek())),
|
||||
concatMap(() => this.syncNotifier.handleSpecial(this.serverModel.peek())),
|
||||
tap(() => this.$synced$.next()),
|
||||
catchError(e => of(console.error(`Exception in sync service`, e))),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user