Skip to content

Commit

Permalink
chore: Remove eslint-disable comments where no longer needed; feat: A…
Browse files Browse the repository at this point in the history
…lways fetch the latest article whenever the Article Viewer page is refreshed
  • Loading branch information
mwiraszka committed Nov 4, 2024
1 parent 5ad6234 commit aed1047
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 25 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ Welcome to the source code repository for the LCC web app! Here you'll find an o
v4.1.5 - November 3rd, 2024
</summary>

- 🚀 Add ability to show/hide sensitive information when logged in as admin wherever personal details may be displayed
- 🚀 Add ability to show/hide sensitive information when logged in as admin wherever personal details may be displayed
- 🐛 Always fetch the latest article whenever the Article Viewer page is refreshed

</details>

Expand Down
1 change: 0 additions & 1 deletion src/app/services/articles.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import { Observable, of } from 'rxjs';
import { catchError, map, switchMap } from 'rxjs/operators';

Expand Down
1 change: 0 additions & 1 deletion src/app/services/members.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import { Observable, of } from 'rxjs';
import { catchError, map, switchMap } from 'rxjs/operators';

Expand Down
1 change: 0 additions & 1 deletion src/app/services/schedule.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import { Observable, of } from 'rxjs';
import { catchError, map, switchMap } from 'rxjs/operators';

Expand Down
22 changes: 19 additions & 3 deletions src/app/store/articles/articles.effects.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import { Actions, createEffect, ofType } from '@ngrx/effects';
import { concatLatestFrom } from '@ngrx/operators';
import { Store } from '@ngrx/store';
Expand All @@ -9,7 +8,12 @@ import { Injectable } from '@angular/core';

import { ArticlesService, ImagesService, LoaderService } from '@app/services';
import { AuthSelectors } from '@app/store/auth';
import type { Article, ModificationInfo, ServiceResponse } from '@app/types';
import {
type Article,
ControlModes,
type ModificationInfo,
type ServiceResponse,
} from '@app/types';
import { isDefined } from '@app/utils';

import * as ArticlesActions from './articles.actions';
Expand Down Expand Up @@ -175,9 +179,21 @@ export class ArticlesEffects {
);
});

updateArticleInArticleViewer$ = createEffect(() => {
return this.actions$.pipe(
ofType(ArticlesActions.fetchArticleSucceeded),
map(({ article }) =>
ArticlesActions.setArticle({
article,
controlMode: ControlModes.VIEW,
}),
),
);
});

requestImageUrl$ = createEffect(() => {
return this.actions$.pipe(
ofType(ArticlesActions.fetchArticleSucceeded, ArticlesActions.setArticle),
ofType(ArticlesActions.setArticle),
map(({ article }) => article.imageId),
filter(isDefined),
map(imageId => ArticlesActions.getArticleImageUrlRequested({ imageId })),
Expand Down
1 change: 0 additions & 1 deletion src/app/store/auth/auth.effects.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import { Actions, createEffect, ofType } from '@ngrx/effects';
import { concatLatestFrom } from '@ngrx/operators';
import { Store } from '@ngrx/store';
Expand Down
1 change: 0 additions & 1 deletion src/app/store/members/members.effects.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import { Actions, createEffect, ofType } from '@ngrx/effects';
import { concatLatestFrom } from '@ngrx/operators';
import { Store } from '@ngrx/store';
Expand Down
18 changes: 2 additions & 16 deletions src/app/store/nav/nav.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,8 @@ export class NavEffects {
ofType(routerNavigatedAction),
filter(({ payload }) => payload.event.url.startsWith('/article/view/')),
map(({ payload }) => {
const currentPath = payload.event.url;
const articleId = currentPath.split('/article/view/')[1].split('#')[0];
return { currentPath, articleId };
}),
concatLatestFrom(() => this.store.select(NavSelectors.previousPath)),
filter(([{ currentPath }, previousPath]) => currentPath !== previousPath),
concatLatestFrom(([{ articleId }]) =>
this.store.select(ArticlesSelectors.articleById(articleId)),
),
map(([[{ articleId }], articleInStore]) => {
return articleInStore
? ArticlesActions.setArticle({
article: articleInStore,
controlMode: ControlModes.VIEW,
})
: ArticlesActions.fetchArticleRequested({ articleId });
const articleId = payload.event.url.split('/article/view/')[1].split('#')[0];
return ArticlesActions.fetchArticleRequested({ articleId });
}),
),
);
Expand Down

0 comments on commit aed1047

Please sign in to comment.