diff --git a/src/Squidex/app/features/administration/state/users.state.ts b/src/Squidex/app/features/administration/state/users.state.ts index 7a81804ec..ec8178a42 100644 --- a/src/Squidex/app/features/administration/state/users.state.ts +++ b/src/Squidex/app/features/administration/state/users.state.ts @@ -210,8 +210,8 @@ export class UsersState extends State { private replaceUser(userDto: UserDto) { return this.next(s => { const user = this.createUser(userDto); - const users = s.users.replaceBy('id', user); + const selectedUser = s.selectedUser && s.selectedUser.user.id === userDto.id ? user : s.selectedUser; return { ...s, users, selectedUser }; diff --git a/src/Squidex/app/shared/state/apps.state.ts b/src/Squidex/app/shared/state/apps.state.ts index 7bbb909ce..672fd1649 100644 --- a/src/Squidex/app/shared/state/apps.state.ts +++ b/src/Squidex/app/shared/state/apps.state.ts @@ -80,9 +80,7 @@ export class AppsState extends State { return observable .do(selectedApp => { - this.next(s => { - return { ...s, selectedApp }; - }); + this.next(s => ({ ...s, selectedApp })); }); } @@ -90,7 +88,9 @@ export class AppsState extends State { return this.appsService.getApps() .do(dtos => { this.next(s => { - return { ...s, apps: ImmutableArray.of(dtos) }; + const apps = ImmutableArray.of(dtos); + + return { ...s, apps }; }); }); } @@ -99,7 +99,9 @@ export class AppsState extends State { return this.appsService.postApp(request) .do(dto => { this.next(s => { - return { ...s, apps: s.apps.push(dto).sortByStringAsc(x => x.name) }; + const apps = s.apps.push(dto).sortByStringAsc(x => x.name); + + return { ...s, apps }; }); }); } @@ -108,9 +110,11 @@ export class AppsState extends State { return this.appsService.deleteApp(name) .do(app => { this.next(s => { + const apps = s.apps.filter(x => x.name !== name); + const selectedApp = s.selectedApp && s.selectedApp.name === name ? null : s.selectedApp; - return { apps: s.apps.filter(x => x.name !== name), selectedApp }; + return { ...s, apps, selectedApp }; }); }); } diff --git a/src/Squidex/app/shared/state/clients.state.ts b/src/Squidex/app/shared/state/clients.state.ts index 505b0c21b..d955eddf2 100644 --- a/src/Squidex/app/shared/state/clients.state.ts +++ b/src/Squidex/app/shared/state/clients.state.ts @@ -73,7 +73,9 @@ export class ClientsState extends State { return this.appClientsService.getClients(this.appName) .do(dtos => { this.next(s => { - return { clients: ImmutableArray.of(dtos.clients), isLoaded: true, version: dtos.version }; + const clients = ImmutableArray.of(dtos.clients); + + return { ...s, clients, isLoaded: true, version: dtos.version }; }); }) .notify(this.dialogs); diff --git a/src/Squidex/app/shared/state/patterns.state.ts b/src/Squidex/app/shared/state/patterns.state.ts index e1c3a3adf..5ff47fe2a 100644 --- a/src/Squidex/app/shared/state/patterns.state.ts +++ b/src/Squidex/app/shared/state/patterns.state.ts @@ -80,7 +80,9 @@ export class PatternsState extends State { return this.appPatternsService.getPatterns(this.appName) .do(dtos => { this.next(s => { - return { patterns: ImmutableArray.of(dtos.patterns), isLoaded: true, version: dtos.version }; + const patterns = ImmutableArray.of(dtos.patterns).sortByStringAsc(x => x.name); + + return { ...s, patterns, isLoaded: true, version: dtos.version }; }); }) .notify(this.dialogs);