Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
"playwright": "^1.58.0",
"prettier": "^3.8.1",
"typescript": "~5.9.3",
"vitest": "^4.0.18"
"vitest": "^4.0.18",
"zone.js": "~0.16.0"
},
"lint-staged": {
"*.{ts,html,css,json,md}": "prettier --write"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ProfileService } from '../services/profile.service';
import { Profile } from '../models/profile.model';
import { ArticleListConfig } from '../../article/models/article-list-config.model';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { switchMap } from 'rxjs/operators';

@Component({
selector: 'app-profile-articles',
Expand All @@ -25,9 +26,11 @@ export default class ProfileArticlesComponent implements OnInit {
) {}

ngOnInit(): void {
this.profileService
.get(this.route.snapshot.params['username'])
.pipe(takeUntilDestroyed(this.destroyRef))
this.route.paramMap
.pipe(
switchMap(params => this.profileService.get(params.get('username')!)),
takeUntilDestroyed(this.destroyRef),
)
.subscribe({
next: (profile: Profile) => {
this.profile.set(profile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ProfileService } from '../services/profile.service';
import { Profile } from '../models/profile.model';
import { ArticleListConfig } from '../../article/models/article-list-config.model';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { switchMap } from 'rxjs/operators';

@Component({
selector: 'app-profile-favorites',
Expand All @@ -25,9 +26,11 @@ export default class ProfileFavoritesComponent implements OnInit {
) {}

ngOnInit() {
this.profileService
.get(this.route.parent?.snapshot.params['username'])
.pipe(takeUntilDestroyed(this.destroyRef))
this.route
.parent!.paramMap.pipe(
switchMap(params => this.profileService.get(params.get('username')!)),
takeUntilDestroyed(this.destroyRef),
)
.subscribe({
next: (profile: Profile) => {
this.profile.set(profile);
Expand Down
15 changes: 10 additions & 5 deletions src/app/features/profile/pages/profile/profile.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,17 @@ export class ProfileComponent implements OnInit {
) {}

ngOnInit() {
this.profileService
.get(this.route.snapshot.params['username'])
this.route.paramMap
.pipe(
catchError(error => {
this.errors.set(error.errors || { error: ['Failed to load profile'] });
return EMPTY;
switchMap(params => {
this.profile.set(null);
this.errors.set(null);
return this.profileService.get(params.get('username')!).pipe(
catchError(error => {
this.errors.set(error.errors || { error: ['Failed to load profile'] });
return EMPTY;
}),
);
}),
switchMap(profile => {
return combineLatest([of(profile), this.userService.currentUser]);
Expand Down
Loading