fix public work author display
This commit is contained in:
@@ -149,6 +149,7 @@ import {
|
||||
isWoodenFishGalleryEntry,
|
||||
type PlatformPublicGalleryCard,
|
||||
type PlatformWorldCardLike,
|
||||
resolvePlatformWorkAuthorDisplayName,
|
||||
resolvePlatformPublicWorkCode,
|
||||
resolvePlatformWorldCoverImage,
|
||||
resolvePlatformWorldCoverSlides,
|
||||
@@ -655,7 +656,7 @@ function WorldCard({
|
||||
const remixCount = getPlatformWorldRemixCount(entry);
|
||||
const likeCount = getPlatformWorldLikeCount(entry);
|
||||
const typeLabel = describePublicGalleryCardKind(entry);
|
||||
const authorName = resolvePublicEntryAuthorDisplayText(
|
||||
const authorName = resolvePlatformWorkAuthorDisplayName(
|
||||
entry,
|
||||
authorUsername,
|
||||
);
|
||||
@@ -1024,7 +1025,7 @@ function RecommendRuntimeMeta({
|
||||
}) {
|
||||
const likeCount = getPlatformWorldLikeCount(entry);
|
||||
const remixCount = getPlatformWorldRemixCount(entry);
|
||||
const authorName = resolvePublicEntryAuthorDisplayText(
|
||||
const authorName = resolvePlatformWorkAuthorDisplayName(
|
||||
entry,
|
||||
authorUsername,
|
||||
);
|
||||
@@ -1935,17 +1936,6 @@ function getPublicAuthorAvatarLabel(authorDisplayName: string) {
|
||||
return Array.from(authorDisplayName.trim() || '玩')[0] ?? '玩';
|
||||
}
|
||||
|
||||
function resolvePublicEntryAuthorDisplayText(
|
||||
entry: PlatformPublicGalleryCard,
|
||||
authorUsername?: string | null,
|
||||
) {
|
||||
if (isWoodenFishGalleryEntry(entry)) {
|
||||
return authorUsername?.trim() || entry.authorDisplayName.trim() || '玩家';
|
||||
}
|
||||
|
||||
return entry.authorDisplayName.trim() || '玩家';
|
||||
}
|
||||
|
||||
function getPlatformWorldLikeCount(entry: PlatformWorldCardLike) {
|
||||
return Math.max(0, Math.round(entry.likeCount ?? 0));
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
mapWoodenFishWorkToPlatformGalleryCard,
|
||||
type PlatformEdutainmentGalleryCard,
|
||||
type PlatformPuzzleGalleryCard,
|
||||
resolvePlatformWorkAuthorDisplayName,
|
||||
resolvePlatformPublicWorkCode,
|
||||
resolvePlatformWorldFallbackCoverImage,
|
||||
} from './rpgEntryWorldPresentation';
|
||||
@@ -197,6 +198,30 @@ test('maps wooden fish work to platform gallery card with WF public code', () =>
|
||||
expect(buildPlatformWorldDisplayTags(card, 2)).toEqual(['敲木鱼']);
|
||||
});
|
||||
|
||||
test('resolves public work author from live username before stored author name', () => {
|
||||
const card = mapWoodenFishWorkToPlatformGalleryCard({
|
||||
publicWorkCode: 'WF-AUTHOR1',
|
||||
workId: 'wooden-fish-work-author',
|
||||
profileId: 'wooden-fish-profile-author',
|
||||
ownerUserId: 'user-author',
|
||||
authorDisplayName: '敲木鱼玩家',
|
||||
workTitle: '莲花木鱼',
|
||||
workDescription: '莲花主题敲木鱼。',
|
||||
coverImageSrc: null,
|
||||
themeTags: ['敲木鱼'],
|
||||
publicationStatus: 'published',
|
||||
playCount: 0,
|
||||
updatedAt: '2026-05-20T00:00:00.000Z',
|
||||
publishedAt: '2026-05-20T00:00:00.000Z',
|
||||
generationStatus: 'ready',
|
||||
});
|
||||
|
||||
expect(resolvePlatformWorkAuthorDisplayName(card, 'lotus_user')).toBe(
|
||||
'lotus_user',
|
||||
);
|
||||
expect(resolvePlatformWorkAuthorDisplayName(card, ' ')).toBe('敲木鱼玩家');
|
||||
});
|
||||
|
||||
test('keeps baby object match public card code and template label intact', () => {
|
||||
const card: PlatformEdutainmentGalleryCard = {
|
||||
sourceType: 'edutainment',
|
||||
|
||||
@@ -862,6 +862,13 @@ export function formatPlatformWorkDisplayTags(
|
||||
].slice(0, limit);
|
||||
}
|
||||
|
||||
export function resolvePlatformWorkAuthorDisplayName(
|
||||
entry: PlatformPublicGalleryCard,
|
||||
authorUsername?: string | null,
|
||||
) {
|
||||
return authorUsername?.trim() || entry.authorDisplayName.trim() || '玩家';
|
||||
}
|
||||
|
||||
export function buildPlatformWorldDisplayTags(
|
||||
entry: PlatformWorldCardLike,
|
||||
limit = 3,
|
||||
|
||||
Reference in New Issue
Block a user