fix public author display
This commit is contained in:
@@ -15294,9 +15294,7 @@ export function PlatformEntryFlowShellImpl({
|
||||
>
|
||||
<PlatformWorkDetailView
|
||||
entry={selectedPublicWorkDetail}
|
||||
authorAvatarUrl={selectedPublicWorkAuthor?.avatarUrl ?? null}
|
||||
authorUsername={selectedPublicWorkAuthor?.username ?? null}
|
||||
authorDisplayName={selectedPublicWorkAuthor?.displayName ?? null}
|
||||
authorSummary={selectedPublicWorkAuthor}
|
||||
isBusy={
|
||||
isPublicWorkDetailBusy ||
|
||||
isPuzzleBusy ||
|
||||
@@ -15342,11 +15340,7 @@ export function PlatformEntryFlowShellImpl({
|
||||
) : selectedDetailEntry.visibility !== 'draft' ? (
|
||||
<PlatformWorkDetailView
|
||||
entry={mapRpgGalleryCardToPublicWorkDetail(selectedDetailEntry)}
|
||||
authorAvatarUrl={selectedPublicWorkAuthor?.avatarUrl ?? null}
|
||||
authorUsername={selectedPublicWorkAuthor?.username ?? null}
|
||||
authorDisplayName={
|
||||
selectedPublicWorkAuthor?.displayName ?? null
|
||||
}
|
||||
authorSummary={selectedPublicWorkAuthor}
|
||||
isBusy={detailNavigation.isMutatingDetail}
|
||||
error={detailNavigation.detailError}
|
||||
actionMode={
|
||||
|
||||
@@ -143,7 +143,13 @@ test('PlatformWorkDetailView prefers resolved public user display name', () => {
|
||||
render(
|
||||
<PlatformWorkDetailView
|
||||
entry={createPuzzleEntry()}
|
||||
authorDisplayName="新的作者昵称"
|
||||
authorSummary={{
|
||||
id: 'user-2',
|
||||
publicUserCode: '',
|
||||
username: 'phone_00000002',
|
||||
displayName: '新的作者昵称',
|
||||
avatarUrl: null,
|
||||
}}
|
||||
isBusy={false}
|
||||
error={null}
|
||||
onBack={vi.fn()}
|
||||
@@ -157,12 +163,17 @@ test('PlatformWorkDetailView prefers resolved public user display name', () => {
|
||||
expect(screen.queryByText('137****6613')).toBeNull();
|
||||
});
|
||||
|
||||
test('PlatformWorkDetailView prefers resolved username for wooden fish works', () => {
|
||||
test('PlatformWorkDetailView prefers display name then public user code for wooden fish works', () => {
|
||||
render(
|
||||
<PlatformWorkDetailView
|
||||
entry={createWoodenFishEntry()}
|
||||
authorUsername="lotus_user"
|
||||
authorDisplayName="公开昵称"
|
||||
authorSummary={{
|
||||
id: 'user-4',
|
||||
publicUserCode: 'SY-00000004',
|
||||
username: 'phone_00000004',
|
||||
displayName: '公开昵称',
|
||||
avatarUrl: null,
|
||||
}}
|
||||
isBusy={false}
|
||||
error={null}
|
||||
onBack={vi.fn()}
|
||||
@@ -172,7 +183,8 @@ test('PlatformWorkDetailView prefers resolved username for wooden fish works', (
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(screen.getByText('lotus_user')).toBeTruthy();
|
||||
expect(screen.getByText('公开昵称 · SY-00000004')).toBeTruthy();
|
||||
expect(screen.queryByText('phone_00000004')).toBeNull();
|
||||
expect(screen.queryByText('敲木鱼玩家')).toBeNull();
|
||||
expect(screen.queryByText('公开昵称')).toBeNull();
|
||||
});
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
} from 'lucide-react';
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
|
||||
import type { PublicUserSummary } from '../../../packages/shared/src/contracts/auth';
|
||||
import { buildPublicWorkDetailUrl } from '../../routing/appPageRoutes';
|
||||
import { copyTextToClipboard } from '../../services/clipboard';
|
||||
import { ResolvedAssetImage } from '../ResolvedAssetImage';
|
||||
@@ -33,9 +34,7 @@ import {
|
||||
|
||||
export interface PlatformWorkDetailViewProps {
|
||||
entry: PlatformPublicGalleryCard;
|
||||
authorAvatarUrl?: string | null;
|
||||
authorUsername?: string | null;
|
||||
authorDisplayName?: string | null;
|
||||
authorSummary?: PublicUserSummary | null;
|
||||
isBusy: boolean;
|
||||
error?: string | null;
|
||||
visibleCoverCount?: number;
|
||||
@@ -87,9 +86,7 @@ const PLATFORM_WORK_COVER_CAROUSEL_INTERVAL_MS = 4200;
|
||||
|
||||
export function PlatformWorkDetailView({
|
||||
entry,
|
||||
authorAvatarUrl,
|
||||
authorUsername,
|
||||
authorDisplayName,
|
||||
authorSummary,
|
||||
isBusy,
|
||||
visibleCoverCount = 1,
|
||||
onBack,
|
||||
@@ -111,10 +108,10 @@ export function PlatformWorkDetailView({
|
||||
const appIconImage = coverSlides[0]?.imageSrc ?? '';
|
||||
const hasCoverCarousel = coverSlides.length > 1;
|
||||
const publicWorkCode = resolvePlatformPublicWorkCode(entry);
|
||||
const normalizedAuthorAvatarUrl = authorAvatarUrl?.trim() ?? '';
|
||||
const normalizedAuthorAvatarUrl = authorSummary?.avatarUrl?.trim() ?? '';
|
||||
const resolvedAuthorDisplayName = resolvePlatformWorkAuthorDisplayName(
|
||||
entry,
|
||||
authorUsername?.trim() || authorDisplayName?.trim() || null,
|
||||
authorSummary,
|
||||
);
|
||||
const [copyState, setCopyState] = useState<'idle' | 'copied' | 'failed'>(
|
||||
'idle',
|
||||
|
||||
Reference in New Issue
Block a user