diff options
Diffstat (limited to 'client/src/app/core/plugins/hooks.service.ts')
-rw-r--r-- | client/src/app/core/plugins/hooks.service.ts | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/client/src/app/core/plugins/hooks.service.ts b/client/src/app/core/plugins/hooks.service.ts index ec47aa48c..ddde198d2 100644 --- a/client/src/app/core/plugins/hooks.service.ts +++ b/client/src/app/core/plugins/hooks.service.ts | |||
@@ -3,13 +3,29 @@ import { mergeMap, switchMap } from 'rxjs/operators' | |||
3 | import { Injectable } from '@angular/core' | 3 | import { Injectable } from '@angular/core' |
4 | import { PluginService } from '@app/core/plugins/plugin.service' | 4 | import { PluginService } from '@app/core/plugins/plugin.service' |
5 | import { ClientActionHookName, ClientFilterHookName, PluginClientScope } from '@shared/models' | 5 | import { ClientActionHookName, ClientFilterHookName, PluginClientScope } from '@shared/models' |
6 | import { AuthService, AuthStatus } from '../auth' | ||
6 | 7 | ||
7 | type RawFunction<U, T> = (params: U) => T | 8 | type RawFunction<U, T> = (params: U) => T |
8 | type ObservableFunction<U, T> = RawFunction<U, Observable<T>> | 9 | type ObservableFunction<U, T> = RawFunction<U, Observable<T>> |
9 | 10 | ||
10 | @Injectable() | 11 | @Injectable() |
11 | export class HooksService { | 12 | export class HooksService { |
12 | constructor (private pluginService: PluginService) { } | 13 | constructor ( |
14 | private authService: AuthService, | ||
15 | private pluginService: PluginService | ||
16 | ) { | ||
17 | // Run auth hooks | ||
18 | this.authService.userInformationLoaded | ||
19 | .subscribe(() => this.runAction('action:auth-user.information-loaded', 'common', { user: this.authService.getUser() })) | ||
20 | |||
21 | this.authService.loginChangedSource.subscribe(obj => { | ||
22 | if (obj === AuthStatus.LoggedIn) { | ||
23 | this.runAction('action:auth-user.logged-in', 'common') | ||
24 | } else if (obj === AuthStatus.LoggedOut) { | ||
25 | this.runAction('action:auth-user.logged-out', 'common') | ||
26 | } | ||
27 | }) | ||
28 | } | ||
13 | 29 | ||
14 | wrapObsFun | 30 | wrapObsFun |
15 | <P, R, H1 extends ClientFilterHookName, H2 extends ClientFilterHookName> | 31 | <P, R, H1 extends ClientFilterHookName, H2 extends ClientFilterHookName> |