From 9958bfdd025511dec5074f9d69dd91d06c845ce1 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Tue, 17 Nov 2026 05:39:56 +0000 Subject: [PATCH] fix: reload profile when the username route param changes --- bun.lock | 5 +++-- package.json | 3 ++- .../components/profile-articles.component.ts | 9 ++++++--- .../components/profile-favorites.component.ts | 9 ++++++--- .../profile/pages/profile/profile.component.ts | 15 ++++++++++----- 5 files changed, 27 insertions(+), 14 deletions(-) diff --git a/bun.lock b/bun.lock index ac785ed3c..08d0e78e8 100644 --- a/bun.lock +++ b/bun.lock @@ -8,7 +8,7 @@ "@angular/animations": "21.1.1", "@angular/common": "21.1.1", "@angular/compiler": "21.1.1", - "@angular/core": "21.1.1", + "@angular/core": "21.2.4", "@angular/forms": "21.1.1", "@angular/platform-browser": "21.1.1", "@angular/platform-browser-dynamic": "21.1.1", @@ -34,6 +34,7 @@ "prettier": "^3.8.1", "typescript": "~5.9.3", "vitest": "^4.0.18", + "zone.js": "~0.16.0", }, }, }, @@ -90,7 +91,7 @@ "@angular/compiler-cli": ["@angular/compiler-cli@21.1.1", "", { "dependencies": { "@babel/core": "7.28.5", "@jridgewell/sourcemap-codec": "^1.4.14", "chokidar": "^5.0.0", "convert-source-map": "^1.5.1", "reflect-metadata": "^0.2.0", "semver": "^7.0.0", "tslib": "^2.3.0", "yargs": "^18.0.0" }, "peerDependencies": { "@angular/compiler": "21.1.1", "typescript": ">=5.9 <6.0" }, "optionalPeers": ["typescript"], "bin": { "ngc": "bundles/src/bin/ngc.js", "ng-xi18n": "bundles/src/bin/ng_xi18n.js" } }, "sha512-CCB8SZS0BzqLOdOaMpPpOW256msuatYCFDRTaT+awYIY1vQp/eLXzkMTD2uqyHraQy8cReeH/P6optRP9A077Q=="], - "@angular/core": ["@angular/core@21.1.1", "", { "dependencies": { "tslib": "^2.3.0" }, "peerDependencies": { "@angular/compiler": "21.1.1", "rxjs": "^6.5.3 || ^7.4.0", "zone.js": "~0.15.0 || ~0.16.0" }, "optionalPeers": ["@angular/compiler", "zone.js"] }, "sha512-KFRCEhsi02pY1EqJ5rnze4mzSaacqh14D8goDhtmARiUH0tefaHR+uKyu4bKSrWga2T/ExG0DJX52LhHRs2qSw=="], + "@angular/core": ["@angular/core@21.2.4", "", { "dependencies": { "tslib": "^2.3.0" }, "peerDependencies": { "@angular/compiler": "21.2.4", "rxjs": "^6.5.3 || ^7.4.0", "zone.js": "~0.15.0 || ~0.16.0" }, "optionalPeers": ["@angular/compiler", "zone.js"] }, "sha512-2+gd67ZuXHpGOqeb2o7XZPueEWEP81eJza2tSHkT5QMV8lnYllDEmaNnkPxnIjSLGP1O3PmiXxo4z8ibHkLZwg=="], "@angular/forms": ["@angular/forms@21.1.1", "", { "dependencies": { "@standard-schema/spec": "^1.0.0", "tslib": "^2.3.0" }, "peerDependencies": { "@angular/common": "21.1.1", "@angular/core": "21.1.1", "@angular/platform-browser": "21.1.1", "rxjs": "^6.5.3 || ^7.4.0" } }, "sha512-NBbJOynLOeMsPo03+3dfdxE0P7SB7SXRqoFJ7WP2sOgOIxODna/huo2blmRlnZAVPTn1iQEB9Q+UeyP5c4/1+w=="], diff --git a/package.json b/package.json index 38bd2b29c..220efa1d5 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/src/app/features/profile/components/profile-articles.component.ts b/src/app/features/profile/components/profile-articles.component.ts index 453ec2364..088b6b572 100644 --- a/src/app/features/profile/components/profile-articles.component.ts +++ b/src/app/features/profile/components/profile-articles.component.ts @@ -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', @@ -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); diff --git a/src/app/features/profile/components/profile-favorites.component.ts b/src/app/features/profile/components/profile-favorites.component.ts index a48ee96f1..0f8565663 100644 --- a/src/app/features/profile/components/profile-favorites.component.ts +++ b/src/app/features/profile/components/profile-favorites.component.ts @@ -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', @@ -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); diff --git a/src/app/features/profile/pages/profile/profile.component.ts b/src/app/features/profile/pages/profile/profile.component.ts index 82d89196c..79a8b7443 100644 --- a/src/app/features/profile/pages/profile/profile.component.ts +++ b/src/app/features/profile/pages/profile/profile.component.ts @@ -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]);