mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-10-07 18:22:04 +00:00
feat: use takeUntilDestroy instead of manually unsubscribing
This commit is contained in:
committed by
Rainer Killinger
parent
bebee6b4d0
commit
06f3120345
+11
-23
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 StApps
|
||||
* Copyright (C) 2023 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
@@ -12,41 +12,29 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {OnInit, OnDestroy, Component} from '@angular/core';
|
||||
import {Component} from '@angular/core';
|
||||
import {NavController} from '@ionic/angular';
|
||||
import {Router} from '@angular/router';
|
||||
import {AuthActions, IAuthAction} from 'ionic-appauth';
|
||||
import {Subscription} from 'rxjs';
|
||||
import {SCAuthorizationProviderType} from '@openstapps/core';
|
||||
import {AuthHelperService} from '../../auth-helper.service';
|
||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||
import {Observable} from 'rxjs';
|
||||
import {IPAIAAuthAction} from '../../paia/paia-auth-action';
|
||||
|
||||
@Component({
|
||||
templateUrl: 'auth-callback-page.component.html',
|
||||
styleUrls: ['auth-callback-page.component.scss'],
|
||||
})
|
||||
export class AuthCallbackPageComponent implements OnInit, OnDestroy {
|
||||
export class AuthCallbackPageComponent {
|
||||
PROVIDER_TYPE: SCAuthorizationProviderType = 'default';
|
||||
|
||||
private authEvents: Subscription;
|
||||
constructor(private navCtrl: NavController, private router: Router, private authHelper: AuthHelperService) {
|
||||
const provider = this.authHelper.getProvider(this.PROVIDER_TYPE);
|
||||
const events: Observable<IPAIAAuthAction | IAuthAction> = provider.events$;
|
||||
|
||||
constructor(
|
||||
private navCtrl: NavController,
|
||||
private router: Router,
|
||||
private authHelper: AuthHelperService,
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.authEvents = this.authHelper
|
||||
.getProvider(this.PROVIDER_TYPE)
|
||||
.events$.subscribe((action: IAuthAction) => this.postCallback(action));
|
||||
this.authHelper
|
||||
.getProvider(this.PROVIDER_TYPE)
|
||||
.authorizationCallback(window.location.origin + this.router.url);
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.authEvents.unsubscribe();
|
||||
events.pipe(takeUntilDestroyed()).subscribe((action: IAuthAction) => this.postCallback(action));
|
||||
provider.authorizationCallback(window.location.origin + this.router.url);
|
||||
}
|
||||
|
||||
async postCallback(action: IAuthAction) {
|
||||
|
||||
Reference in New Issue
Block a user