Browse Source
Bugfix/force reload accounts of user after change (#994)
* Force reload of accounts after change
* Update changelog
pull/1000/head
Thomas Kaul
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with
24 additions and
3 deletions
-
CHANGELOG.md
-
apps/api/src/app/user/user.service.ts
-
apps/client/src/app/pages/accounts/accounts-page.component.ts
-
apps/client/src/app/services/user/user-store.actions.ts
-
apps/client/src/app/services/user/user.service.ts
|
|
@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 |
|
|
|
|
|
|
|
### Fixed |
|
|
|
|
|
|
|
- Reloaded the accounts of a user after creating, editing or deleting one |
|
|
|
- Excluded empty items in the activities filter |
|
|
|
|
|
|
|
## 1.156.0 - 05.06.2022 |
|
|
|
|
|
@ -12,6 +12,7 @@ import { |
|
|
|
} from '@ghostfolio/common/permissions'; |
|
|
|
import { Injectable } from '@nestjs/common'; |
|
|
|
import { Prisma, Role, User, ViewMode } from '@prisma/client'; |
|
|
|
import { sortBy } from 'lodash'; |
|
|
|
|
|
|
|
import { UserSettingsParams } from './interfaces/user-settings-params.interface'; |
|
|
|
import { UserSettings } from './interfaces/user-settings.interface'; |
|
|
@ -185,6 +186,9 @@ export class UserService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
user.Account = sortBy(user.Account, (account) => { |
|
|
|
return account.name; |
|
|
|
}); |
|
|
|
user.permissions = currentPermissions.sort(); |
|
|
|
|
|
|
|
return user; |
|
|
|
|
|
@ -133,6 +133,11 @@ export class AccountsPageComponent implements OnDestroy, OnInit { |
|
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
|
.subscribe({ |
|
|
|
next: () => { |
|
|
|
this.userService |
|
|
|
.get(true) |
|
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
|
.subscribe(); |
|
|
|
|
|
|
|
this.fetchAccounts(); |
|
|
|
} |
|
|
|
}); |
|
|
@ -179,6 +184,11 @@ export class AccountsPageComponent implements OnDestroy, OnInit { |
|
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
|
.subscribe({ |
|
|
|
next: () => { |
|
|
|
this.userService |
|
|
|
.get(true) |
|
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
|
.subscribe(); |
|
|
|
|
|
|
|
this.fetchAccounts(); |
|
|
|
} |
|
|
|
}); |
|
|
@ -220,6 +230,11 @@ export class AccountsPageComponent implements OnDestroy, OnInit { |
|
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
|
.subscribe({ |
|
|
|
next: () => { |
|
|
|
this.userService |
|
|
|
.get(true) |
|
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
|
.subscribe(); |
|
|
|
|
|
|
|
this.fetchAccounts(); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
@ -1,4 +1,5 @@ |
|
|
|
export enum UserStoreActions { |
|
|
|
GetUser = 'GET_USER', |
|
|
|
Initialize = 'INITIALIZE', |
|
|
|
RemoveUser = 'REMOVE_USER' |
|
|
|
} |
|
|
|
|
|
@ -16,13 +16,13 @@ export class UserService extends ObservableStore<UserStoreState> { |
|
|
|
public constructor(private http: HttpClient) { |
|
|
|
super({ trackStateHistory: true }); |
|
|
|
|
|
|
|
this.setState({ user: undefined }, 'INIT_STATE'); |
|
|
|
this.setState({ user: undefined }, UserStoreActions.Initialize); |
|
|
|
} |
|
|
|
|
|
|
|
public get() { |
|
|
|
public get(force = false) { |
|
|
|
const state = this.getState(); |
|
|
|
|
|
|
|
if (state?.user) { |
|
|
|
if (state?.user && force !== true) { |
|
|
|
// Get from cache
|
|
|
|
return of(state.user); |
|
|
|
} else { |
|
|
|