-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.component.ts
More file actions
35 lines (33 loc) · 1.07 KB
/
Copy pathapp.component.ts
File metadata and controls
35 lines (33 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// app.component.ts
import { Component, effect, inject } from '@angular/core';
import { IonApp, IonRouterOutlet } from '@ionic/angular/standalone';
import { NavController, ToastController } from '@ionic/angular';
import { ThemeService } from './core/services/theme.service';
@Component({
selector: 'app-root',
templateUrl: 'app.component.html',
imports: [IonApp, IonRouterOutlet],
})
export class AppComponent {
private navCtrl = inject(NavController);
private toastCtrl = inject(ToastController);
private readonly themeService = inject(ThemeService);
constructor() {
effect(async () => {
if (localStorage.getItem('pending_backend_change')) {
localStorage.removeItem('pending_backend_change');
this.navCtrl.navigateRoot('/login');
this.showToast('The backend successfully switched!');
}
});
}
private async showToast(message: string): Promise<void> {
const toast = await this.toastCtrl.create({
message,
duration: 3000,
position: 'bottom',
color: 'success',
});
await toast.present();
}
}