Skip to content

Commit

Permalink
feat: show user highlight & follow name
Browse files Browse the repository at this point in the history
  • Loading branch information
juanfran committed Feb 20, 2025
1 parent d0ddcb8 commit 264ec57
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
11 changes: 11 additions & 0 deletions apps/web/src/app/modules/board/reducers/boardPage.reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ export const boardPageFeature = createFeature({
selectUserHighlight,
selectShowUserVotes,
selectFocusId,
selectBoardUsers,
}) => ({
isFocus: (id: string) => {
return createSelector(selectFocusId, (focusId) => focusId.includes(id));
Expand All @@ -532,6 +533,16 @@ export const boardPageFeature = createFeature({
return id ? !!id : !!userVotes;
},
),
userHighlightInfo: createSelector(
selectUserHighlight,
selectShowUserVotes,
selectBoardUsers,
(userHighlight, userVotes, users) => {
return users.find(
(it) => it.id === userHighlight || it.id === userVotes,
);
},
),
selectMoveEnabled: createSelector(
selectMoveEnabled,
selectFollow,
Expand Down
14 changes: 8 additions & 6 deletions apps/web/src/app/shared/follow-user/follow-user.component.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import { ChangeDetectionStrategy, Component, inject } from '@angular/core';
import { CommonModule } from '@angular/common';
import { Store } from '@ngrx/store';
import { boardPageFeature } from '../../modules/board/reducers/boardPage.reducer';
import { map, switchMap } from 'rxjs';
import { filterNil } from '../../commons/operators/filter-nil';
import { BoardPageActions } from '../../modules/board/actions/board-page.actions';
import { MatButtonModule } from '@angular/material/button';
import { BoardFacade } from '../../services/board-facade.service';
import { toSignal } from '@angular/core/rxjs-interop';

@Component({
selector: 'tapiz-follow-user',
imports: [CommonModule, MatButtonModule],
imports: [MatButtonModule],
template: `
@if (userToFollow$ | async) {
@if (userToFollow(); as user) {
<button
(click)="stopFollowingUser()"
mat-raised-button
color="primary">
Stop following user
Stop following {{ user.name }}
</button>
}
`,
Expand All @@ -28,7 +28,7 @@ export class FollowUserComponent {
#store = inject(Store);
#boardFacade = inject(BoardFacade);

userToFollow$ = this.#store.select(boardPageFeature.selectFollow).pipe(
#userToFollow$ = this.#store.select(boardPageFeature.selectFollow).pipe(
switchMap((follow) => {
return this.#boardFacade.getUsers().pipe(
map((users) => {
Expand All @@ -38,12 +38,14 @@ export class FollowUserComponent {
}),
);

userToFollow = toSignal(this.#userToFollow$);

stopFollowingUser() {
this.#store.dispatch(BoardPageActions.followUser({ id: '' }));
}

constructor() {
this.userToFollow$.pipe(filterNil()).subscribe((user) => {
this.#userToFollow$.pipe(filterNil()).subscribe((user) => {
if (user.position && user.zoom) {
this.#store.dispatch(
BoardPageActions.setUserView({
Expand Down
6 changes: 3 additions & 3 deletions apps/web/src/app/shared/stop-highlight/stop-highlight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import { boardPageFeature } from '../../modules/board/reducers/boardPage.reducer
selector: 'tapiz-stop-highlight',
imports: [MatButtonModule],
template: `
@if (highlight()) {
@if (highlight(); as user) {
<button
(click)="stop()"
mat-raised-button
color="primary">
Stop highlight user
Stop highlight {{ user.name }}
</button>
}
`,
Expand All @@ -24,7 +24,7 @@ import { boardPageFeature } from '../../modules/board/reducers/boardPage.reducer
export class StopHighlightComponent {
#store = inject(Store);

highlight = this.#store.selectSignal(boardPageFeature.isUserHighlighActive);
highlight = this.#store.selectSignal(boardPageFeature.userHighlightInfo);

stop() {
this.#store.dispatch(BoardPageActions.stopHighlight());
Expand Down

0 comments on commit 264ec57

Please sign in to comment.