u
This commit is contained in:
@@ -352,6 +352,13 @@ export function updateArticleInCategoryViews(article) {
|
||||
// Update in-place
|
||||
const existing = item.data.articles[existingIndex];
|
||||
const updatedArticles = [...item.data.articles];
|
||||
const firstPhoto = Array.isArray(article.photos) && article.photos.length > 0 ? article.photos[0] : null;
|
||||
const hasPhotosProp = 'photos' in article;
|
||||
const fullHash = article.fullHash ?? firstPhoto?.fullHash ?? (hasPhotosProp ? null : existing.fullHash);
|
||||
const thumbHash = article.thumbHash ?? firstPhoto?.thumbHash ?? (hasPhotosProp ? null : existing.thumbHash);
|
||||
const photos = article.photos ?? (hasPhotosProp ? [] : (existing.photos ?? []));
|
||||
const smallThumbBinary = article.smallThumbBinary ?? firstPhoto?.smallThumbBinary ?? (hasPhotosProp ? null : existing.smallThumbBinary);
|
||||
|
||||
updatedArticles[existingIndex] = {
|
||||
...existing,
|
||||
...article,
|
||||
@@ -365,6 +372,10 @@ export function updateArticleInCategoryViews(article) {
|
||||
brandName: article.brand?.name ?? article.brandName ?? existing.brandName,
|
||||
childCount: article.childCount ?? existing.childCount,
|
||||
isParent: Boolean(article.childCount > 0 || article.isParent || existing.isParent),
|
||||
fullHash,
|
||||
thumbHash,
|
||||
photos,
|
||||
smallThumbBinary,
|
||||
};
|
||||
categoryViews.key(slug).set({
|
||||
...item.data,
|
||||
|
||||
Reference in New Issue
Block a user