refactor: get appropriate provider via auth helper

This commit is contained in:
Jovan Krunić
2022-02-14 11:12:02 +01:00
parent a5e5a5b407
commit eaf9da3c84
21 changed files with 141 additions and 182 deletions

View File

@@ -18,8 +18,6 @@ import {App, URLOpenListenerEvent} from '@capacitor/app';
import {SplashScreen} from '@capacitor/splash-screen';
import {Platform, ToastController} from '@ionic/angular';
import {SettingsProvider} from './modules/settings/settings.provider';
import {PAIAAuthService} from './modules/auth/paia/paia-auth.service';
import {DefaultAuthService} from './modules/auth/default-auth.service';
import {AuthHelperService} from './modules/auth/auth-helper.service';
import {ScheduleSyncService} from './modules/background/schedule/schedule-sync.service';
import {environment} from '../environments/environment';
@@ -52,9 +50,7 @@ export class AppComponent implements AfterContentInit {
* @param settingsProvider TODO
* @param router The angular router
* @param zone The angular zone
* @param defaultAuth Auth Service
* @param paiaAuth Auth Service
* @param authHelperService Helper service for OAuth providers
* @param authHelper Helper service for OAuth providers
* @param toastController Toast controller
* @param scheduleSync TODO
*/
@@ -63,9 +59,7 @@ export class AppComponent implements AfterContentInit {
private readonly settingsProvider: SettingsProvider,
private readonly router: Router,
private readonly zone: NgZone,
private readonly defaultAuth: DefaultAuthService,
private readonly paiaAuth: PAIAAuthService,
private readonly authHelperService: AuthHelperService,
private readonly authHelper: AuthHelperService,
private readonly toastController: ToastController,
private readonly scheduleSync: ScheduleSyncService,
) {
@@ -92,8 +86,6 @@ export class AppComponent implements AfterContentInit {
});
this.platform.ready().then(async () => {
await this.authInit();
await this.defaultAuth.init();
await this.paiaAuth.init();
await SplashScreen.hide();
// set order of categories in settings
@@ -107,16 +99,18 @@ export class AppComponent implements AfterContentInit {
}
private async authInit() {
await this.defaultAuth.init();
await this.paiaAuth.init();
this.defaultAuth.events$.subscribe(action =>
this.showMessage(
this.authHelperService.getAuthMessage('default', action),
),
);
this.paiaAuth.events$.subscribe(action =>
this.showMessage(this.authHelperService.getAuthMessage('paia', action)),
);
await this.authHelper.getProvider('default').init();
await this.authHelper.getProvider('paia').init();
this.authHelper
.getProvider('default')
.events$.subscribe(action =>
this.showMessage(this.authHelper.getAuthMessage('default', action)),
);
this.authHelper
.getProvider('paia')
.events$.subscribe(action =>
this.showMessage(this.authHelper.getAuthMessage('paia', action)),
);
}
private async showMessage(message?: string) {