Skip to content

Commit

Permalink
feat(): update cache
Browse files Browse the repository at this point in the history
  • Loading branch information
develite98 committed Nov 10, 2023
1 parent 5284e90 commit 2775d2c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
tuiDropdownDirection="bottom"
>
<div
class="side-menu__item ripple"
class="side-menu__item ripple-gray"
[ngClass]="{
'--open': isMenuSelected(item, selectedMenu),
'--active': isMenuSelected(item, selectedMenu)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="w-100 task-parent-card text-m" [class.--open]="open">
<div class="w-100 task-parent-card text-m ripple-gray" [class.--open]="open">
<mix-button [size]="'xs'" [type]="'icon'" (click)="expandClick.emit()"
><span class="mix-icon expand-icon text-xxl">expand_more</span>
</mix-button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@ export class TaskParentCardComponent {
});
}

public ngOnInit() {
if (!this.task.reporter) return;
public ngOnChanges() {
if (!this.task.reporter || this.userInfo()) return;

this.userInfoStore
.getUserById(this.task.reporter)
.pipe(take(1))
.subscribe((info) => this.userInfo.set(info));
.subscribe((info) => {
this.userInfo.set(info);
});
}
}
68 changes: 2 additions & 66 deletions libs/mix-share/src/stores/user-info.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,68 +2,7 @@ import { Injectable } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { PaginationRequestModel, UserListVm } from '@mixcore/lib/model';
import { BaseCRUDStore } from '@mixcore/share/base';
import { filter, map, switchMap, tap } from 'rxjs';

// @Injectable({ providedIn: 'root' })
// export class UserInfoStore extends ComponentStore<BaseState<UserListVm>> {
// public mixApi = inject(MixApiFacadeService);
// public vm$ = this.select((s) => s);
// public request$ = this.select((s) => s.request);

// public requestFn = (request: PaginationRequestModel) =>
// this.mixApi.accountApi.getUserList({ ...request, loadNestedData: true });

// public getUserById = (userId: string) => {
// return this.vm$.pipe(
// filter((s) => s.status === 'Success'),
// map((s) => {
// return s.data.find((user) => user.id === userId);
// })
// );
// };

// public loadData(request: PaginationRequestModel) {
// return this.requestFn(request).pipe(
// tap((result) => {
// this.patchState((s) => ({
// ...s,
// data: result.items,
// pageInfo: result.pagingData,
// status: 'Success',
// }));
// })
// );
// }

// public reload() {
// this.requestFn(this.get().request).subscribe();
// }

// constructor() {
// super({
// status: 'Loading',
// request: {
// pageIndex: 0,
// pageSize: 50,
// direction: 'Desc',
// searchMethod: 'Like',
// columns: '',
// orderBy: 'createdDateTime',
// metadataQueries: [],
// },
// data: DEFAULT_DATA.items,
// pageInfo: DEFAULT_DATA.pagingData,
// });

// this.request$
// .pipe(
// tap(() => this.patchState((s) => ({ ...s, status: 'Loading' }))),
// switchMap((request) => this.loadData(request)),
// takeUntilDestroyed()
// )
// .subscribe();
// }
// }
import { map, tap } from 'rxjs';

@Injectable({ providedIn: 'root' })
export class UserInfoStore extends BaseCRUDStore<UserListVm> {
Expand All @@ -77,13 +16,10 @@ export class UserInfoStore extends BaseCRUDStore<UserListVm> {
public override requestName = 'mixUserInfo';
public override searchColumns = [];
public override searchColumnsDict: { [key: string]: string } = {};
public override vm$ = this.request$$.pipe(
switchMap(() => this.select((s) => s))
);
public override vm$ = this.select((s) => s);

public getUserById = (userId: string) => {
return this.vm$.pipe(
filter((s) => s.status === 'Success'),
map((s) => {
return s.data.find((user) => user.id === userId);
})
Expand Down

1 comment on commit 2775d2c

@vercel
Copy link

@vercel vercel bot commented on 2775d2c Nov 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.