diff --git a/src/app/xtream/portal.store.ts b/src/app/xtream/portal.store.ts index 10c311a7c..299e2a908 100644 --- a/src/app/xtream/portal.store.ts +++ b/src/app/xtream/portal.store.ts @@ -3,6 +3,7 @@ import { ComponentStore } from '@ngrx/component-store'; export interface PortalState { searchPhrase: string; + content: any[]; } @Injectable({ providedIn: 'root' }) @@ -10,12 +11,16 @@ export class PortalStore extends ComponentStore { constructor() { super({ searchPhrase: '', + content: [], }); } // selectors readonly searchPhrase = this.selectSignal((state) => state.searchPhrase); + readonly getContentById = (id: string) => + this.selectSignal((state) => state.content.find((i) => i.id === id)); + // reducers readonly setSearchPhrase = this.updater( (state, searchPhrase: string): PortalState => ({ @@ -23,4 +28,11 @@ export class PortalStore extends ComponentStore { searchPhrase, }) ); + + readonly setContent = this.updater( + (state, content: any[]): PortalState => ({ + ...state, + content, + }) + ); }