Skip to content
Open
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
29 changes: 7 additions & 22 deletions src/app/features/profile/components/profile-articles.component.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { ChangeDetectionStrategy, Component, DestroyRef, inject, OnInit, signal } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { ArticleListComponent } from '../../article/components/article-list.component';
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 @@ -16,31 +13,19 @@ import { switchMap } from 'rxjs/operators';
changeDetection: ChangeDetectionStrategy.OnPush,
})
export default class ProfileArticlesComponent implements OnInit {
profile = signal<Profile | null>(null);
articlesConfig = signal<ArticleListConfig | null>(null);
destroyRef = inject(DestroyRef);

constructor(
private route: ActivatedRoute,
private readonly profileService: ProfileService,
) {}
constructor(private route: ActivatedRoute) {}

ngOnInit(): void {
this.route.paramMap
.pipe(
switchMap(params => this.profileService.get(params.get('username')!)),
takeUntilDestroyed(this.destroyRef),
)
.subscribe({
next: (profile: Profile) => {
this.profile.set(profile);
this.articlesConfig.set({
type: 'all',
filters: {
author: profile.username,
},
});
this.route.parent!.paramMap.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(params => {
this.articlesConfig.set({
type: 'all',
filters: {
author: params.get('username')!,

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Profile tabs use unverified URL usernames

When a profile lookup resolves a username differently from the URL, articlesConfig uses the URL value instead of the returned username. Check whether profile lookup and article filtering apply the same username matching rules; the favorites tab makes the same change.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

},
});
});
}
}
29 changes: 7 additions & 22 deletions src/app/features/profile/components/profile-favorites.component.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { ChangeDetectionStrategy, Component, DestroyRef, inject, OnInit, signal } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { ArticleListComponent } from '../../article/components/article-list.component';
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 @@ -16,31 +13,19 @@ import { switchMap } from 'rxjs/operators';
changeDetection: ChangeDetectionStrategy.OnPush,
})
export default class ProfileFavoritesComponent implements OnInit {
profile = signal<Profile | null>(null);
favoritesConfig = signal<ArticleListConfig | null>(null);
destroyRef = inject(DestroyRef);

constructor(
private route: ActivatedRoute,
private readonly profileService: ProfileService,
) {}
constructor(private route: ActivatedRoute) {}

ngOnInit() {
this.route
.parent!.paramMap.pipe(
switchMap(params => this.profileService.get(params.get('username')!)),
takeUntilDestroyed(this.destroyRef),
)
.subscribe({
next: (profile: Profile) => {
this.profile.set(profile);
this.favoritesConfig.set({
type: 'all',
filters: {
favorited: profile.username,
},
});
this.route.parent!.paramMap.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(params => {
this.favoritesConfig.set({
type: 'all',
filters: {
favorited: params.get('username')!,
},
});
});
}
}
6 changes: 5 additions & 1 deletion src/app/features/profile/pages/profile/profile.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ export class ProfileComponent implements OnInit {
this.errors.set(null);
return this.profileService.get(params.get('username')!).pipe(
catchError(error => {
this.errors.set(error.errors || { error: ['Failed to load profile'] });
this.errors.set(
error.status === 404
? { errors: { profile: ['not found'] } }
: { errors: error.errors ?? { profile: ['could not be loaded'] } },
Comment on lines +51 to +52

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧠 TD French Language (Bill 96): English-only profile error messages

On lookup failures, ProfileComponent hard-codes “profile not found” and the fallback “profile could not be loaded”. ListErrorsComponent renders these without translation. Canadian French equivalents are profile.notFound: « Profil introuvable » and profile.loadFailed: « Impossible de charger le profil ».

View in Devin Review · Custom reviewer

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

);
return EMPTY;
}),
);
Expand Down