fix: reversed image and icon for remote categories, omit fa icon if remote category has icon property set, #13255

This commit is contained in:
Julian Lam
2025-04-03 11:52:01 -04:00
parent 34ab677174
commit dabcefafd4

View File

@@ -242,7 +242,7 @@ Mocks.category = async (actors) => {
const cid = actor.id; const cid = actor.id;
let hostname; let hostname;
let { let {
url, preferredUsername, /* icon, */ image, url, preferredUsername, icon, /* image, */
name, summary, followers, inbox, endpoints, tag, name, summary, followers, inbox, endpoints, tag,
} = actor; } = actor;
preferredUsername = slugify(preferredUsername || name); preferredUsername = slugify(preferredUsername || name);
@@ -256,13 +256,15 @@ Mocks.category = async (actors) => {
// No support for category avatars yet ;( // No support for category avatars yet ;(
// let picture; // let picture;
// if (icon) { // if (image) {
// picture = typeof icon === 'string' ? icon : icon.url; // picture = typeof image === 'string' ? image : image.url;
// } // }
const iconBackgrounds = await user.getIconBackgrounds(); const iconBackgrounds = await user.getIconBackgrounds();
let bgColor = Array.prototype.reduce.call(preferredUsername, (cur, next) => cur + next.charCodeAt(), 0); let bgColor = Array.prototype.reduce.call(preferredUsername, (cur, next) => cur + next.charCodeAt(), 0);
bgColor = iconBackgrounds[bgColor % iconBackgrounds.length]; bgColor = iconBackgrounds[bgColor % iconBackgrounds.length];
const backgroundImage = !icon || typeof icon === 'string' ? icon : icon.url;
// Replace emoji in summary // Replace emoji in summary
if (tag && Array.isArray(tag)) { if (tag && Array.isArray(tag)) {
tag tag
@@ -281,10 +283,11 @@ Mocks.category = async (actors) => {
slug: `${preferredUsername}@${hostname}`, slug: `${preferredUsername}@${hostname}`,
description: summary, description: summary,
descriptionParsed: posts.sanitize(summary), descriptionParsed: posts.sanitize(summary),
icon: 'fa-comments', icon: backgroundImage ? 'fa-none' : 'fa-comments',
color: '#fff', color: '#fff',
bgColor, bgColor,
backgroundImage: !image || typeof image === 'string' ? image : image.url, backgroundImage,
imageClass: 'cover',
// followerCount, // followerCount,
// followingCount, // followingCount,