Skip to content

Commit d8c2a04

Browse files
committed
fix: person author thumbnail link
1 parent b857fcc commit d8c2a04

File tree

1 file changed

+42
-35
lines changed

1 file changed

+42
-35
lines changed

src/app/persons/persons.component.ts

Lines changed: 42 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -61,53 +61,56 @@ export class PersonsComponent implements OnInit {
6161
if (authors) {
6262
typeId = PictureItemType.PICTURE_ITEM_AUTHOR;
6363
}
64-
return this.#itemsClient.list(
65-
new ItemsRequest({
66-
fields: new ItemFields({
67-
description: true,
68-
hasText: true,
69-
nameDefault: true,
70-
nameHtml: true,
71-
previewPictures: new PreviewPicturesRequest({
72-
pictures: new PicturesRequest({
73-
options: new PictureListOptions({
74-
pictureItem: new PictureItemListOptions({typeId}),
75-
status: PictureStatus.PICTURE_STATUS_ACCEPTED,
64+
return this.#itemsClient
65+
.list(
66+
new ItemsRequest({
67+
fields: new ItemFields({
68+
description: true,
69+
hasText: true,
70+
nameDefault: true,
71+
nameHtml: true,
72+
previewPictures: new PreviewPicturesRequest({
73+
pictures: new PicturesRequest({
74+
options: new PictureListOptions({
75+
pictureItem: new PictureItemListOptions({typeId}),
76+
status: PictureStatus.PICTURE_STATUS_ACCEPTED,
77+
}),
7678
}),
7779
}),
7880
}),
79-
}),
80-
language: this.#languageService.language,
81-
limit: 10,
82-
options: new ItemListOptions({
83-
descendant: new ItemParentCacheListOptions({
84-
pictureItemsByItemId: new PictureItemListOptions({
85-
pictures: new PictureListOptions({status: PictureStatus.PICTURE_STATUS_ACCEPTED}),
86-
typeId,
81+
language: this.#languageService.language,
82+
limit: 10,
83+
options: new ItemListOptions({
84+
descendant: new ItemParentCacheListOptions({
85+
pictureItemsByItemId: new PictureItemListOptions({
86+
pictures: new PictureListOptions({status: PictureStatus.PICTURE_STATUS_ACCEPTED}),
87+
typeId,
88+
}),
8789
}),
90+
typeId: ItemType.ITEM_TYPE_PERSON,
8891
}),
89-
typeId: ItemType.ITEM_TYPE_PERSON,
92+
order: ItemsRequest.Order.NAME,
93+
page,
9094
}),
91-
order: ItemsRequest.Order.NAME,
92-
page,
93-
}),
94-
);
95-
}),
96-
catchError((error: unknown) => {
97-
this.#toastService.handleError(error);
98-
return EMPTY;
95+
)
96+
.pipe(
97+
catchError((error: unknown) => {
98+
this.#toastService.handleError(error);
99+
return EMPTY;
100+
}),
101+
map((response) => ({
102+
items: this.prepareItems(response.items || [], authors),
103+
paginator: response.paginator,
104+
})),
105+
);
99106
}),
100-
map((response) => ({
101-
items: this.prepareItems(response.items || []),
102-
paginator: response.paginator,
103-
})),
104107
);
105108

106109
ngOnInit(): void {
107110
setTimeout(() => this.#pageEnv.set({pageId: 214}), 0);
108111
}
109112

110-
private prepareItems(items: APIItem[]): CatalogueListItem[] {
113+
private prepareItems(items: APIItem[], authors: boolean): CatalogueListItem[] {
111114
return items.map((item): CatalogueListItem => {
112115
const itemRouterLink = ['/persons'];
113116
itemRouterLink.push(item.id);
@@ -119,7 +122,11 @@ export class PersonsComponent implements OnInit {
119122
let routerLink: string[] = [];
120123
if (picture.picture) {
121124
thumb = largeFormat && idx == 0 ? picture.picture.thumbLarge : picture.picture.thumbMedium;
122-
routerLink = itemRouterLink.concat([picture.picture.identity]);
125+
if (authors) {
126+
routerLink = itemRouterLink.concat(['author', picture.picture.identity]);
127+
} else {
128+
routerLink = itemRouterLink.concat([picture.picture.identity]);
129+
}
123130
}
124131
return {picture: picture.picture || null, routerLink, thumb};
125132
});

0 commit comments

Comments
 (0)