1
This commit is contained in:
@@ -171,6 +171,12 @@ function isLibraryEntry(
|
||||
);
|
||||
}
|
||||
|
||||
function isPublishedLibraryEntry(
|
||||
value: unknown,
|
||||
): value is CustomWorldLibraryEntry<CustomWorldProfileRecord> {
|
||||
return isLibraryEntry(value) && value.visibility === 'published';
|
||||
}
|
||||
|
||||
export async function listCustomWorldWorkSummaries(
|
||||
userId: string,
|
||||
dependencies: {
|
||||
@@ -216,8 +222,10 @@ export async function listCustomWorldWorkSummaries(
|
||||
};
|
||||
});
|
||||
|
||||
const publishedItems: CustomWorldWorkSummary[] = profiles.map((profile) => {
|
||||
const libraryEntry = isLibraryEntry(profile) ? profile : null;
|
||||
const publishedItems: CustomWorldWorkSummary[] = profiles
|
||||
.filter((profile) => isPublishedLibraryEntry(profile))
|
||||
.map((profile) => {
|
||||
const libraryEntry = profile;
|
||||
const profileRecord = (
|
||||
libraryEntry?.profile ?? profile
|
||||
) as CustomWorldProfileRecord & Record<string, unknown>;
|
||||
@@ -237,59 +245,55 @@ export async function listCustomWorldWorkSummaries(
|
||||
(entry) => Boolean(toText(entry.generatedAnimationSetId)),
|
||||
).length;
|
||||
|
||||
return {
|
||||
workId: `published:${toText(profileRecord.id) || updatedAt}`,
|
||||
sourceType: 'published_profile',
|
||||
status: 'published',
|
||||
title:
|
||||
(libraryEntry ? toText(libraryEntry.worldName) : '') ||
|
||||
toText(profileRecord.name) ||
|
||||
'未命名世界',
|
||||
subtitle:
|
||||
(libraryEntry ? toText(libraryEntry.subtitle) : '') ||
|
||||
toText(profileRecord.subtitle) ||
|
||||
'已保存作品',
|
||||
summary:
|
||||
(libraryEntry ? toText(libraryEntry.summaryText) : '') ||
|
||||
toText(profileRecord.summary) ||
|
||||
'这个世界已经可以直接进入体验。',
|
||||
coverImageSrc:
|
||||
(libraryEntry ? libraryEntry.coverImageSrc : null) ||
|
||||
coverPresentation.imageSrc,
|
||||
coverRenderMode: coverPresentation.renderMode,
|
||||
coverCharacterImageSrcs: coverPresentation.characterImageSrcs,
|
||||
updatedAt,
|
||||
publishedAt:
|
||||
(libraryEntry ? toText(libraryEntry.publishedAt) : '') ||
|
||||
toText(profileRecord.publishedAt) ||
|
||||
return {
|
||||
workId: `published:${toText(profileRecord.id) || updatedAt}`,
|
||||
sourceType: 'published_profile',
|
||||
status: 'published',
|
||||
title:
|
||||
toText(libraryEntry.worldName) ||
|
||||
toText(profileRecord.name) ||
|
||||
'未命名世界',
|
||||
subtitle:
|
||||
toText(libraryEntry.subtitle) ||
|
||||
toText(profileRecord.subtitle) ||
|
||||
'已保存作品',
|
||||
summary:
|
||||
toText(libraryEntry.summaryText) ||
|
||||
toText(profileRecord.summary) ||
|
||||
'这个世界已经可以直接进入体验。',
|
||||
coverImageSrc: libraryEntry.coverImageSrc || coverPresentation.imageSrc,
|
||||
coverRenderMode: coverPresentation.renderMode,
|
||||
coverCharacterImageSrcs: coverPresentation.characterImageSrcs,
|
||||
updatedAt,
|
||||
stage: 'published',
|
||||
stageLabel: '已发布',
|
||||
playableNpcCount:
|
||||
(libraryEntry?.playableNpcCount ?? 0) > 0
|
||||
? libraryEntry!.playableNpcCount
|
||||
: playableNpcs.length,
|
||||
landmarkCount:
|
||||
(libraryEntry?.landmarkCount ?? 0) > 0
|
||||
? libraryEntry!.landmarkCount
|
||||
: landmarks.length,
|
||||
roleVisualReadyCount,
|
||||
roleAnimationReadyCount,
|
||||
roleAssetSummaryLabel:
|
||||
roleAnimationReadyCount > 0
|
||||
? `动作已就绪 ${roleAnimationReadyCount}`
|
||||
: roleVisualReadyCount > 0
|
||||
? `主图已就绪 ${roleVisualReadyCount}`
|
||||
: null,
|
||||
sessionId: null,
|
||||
profileId:
|
||||
(libraryEntry ? toText(libraryEntry.profileId) : '') ||
|
||||
toText(profileRecord.id) ||
|
||||
null,
|
||||
canResume: false,
|
||||
canEnterWorld: true,
|
||||
};
|
||||
});
|
||||
publishedAt:
|
||||
toText(libraryEntry.publishedAt) ||
|
||||
toText(profileRecord.publishedAt) ||
|
||||
updatedAt,
|
||||
stage: 'published',
|
||||
stageLabel: '已发布',
|
||||
playableNpcCount:
|
||||
libraryEntry.playableNpcCount > 0
|
||||
? libraryEntry.playableNpcCount
|
||||
: playableNpcs.length,
|
||||
landmarkCount:
|
||||
libraryEntry.landmarkCount > 0
|
||||
? libraryEntry.landmarkCount
|
||||
: landmarks.length,
|
||||
roleVisualReadyCount,
|
||||
roleAnimationReadyCount,
|
||||
roleAssetSummaryLabel:
|
||||
roleAnimationReadyCount > 0
|
||||
? `动作已就绪 ${roleAnimationReadyCount}`
|
||||
: roleVisualReadyCount > 0
|
||||
? `主图已就绪 ${roleVisualReadyCount}`
|
||||
: null,
|
||||
sessionId: null,
|
||||
profileId:
|
||||
toText(libraryEntry.profileId) || toText(profileRecord.id) || null,
|
||||
canResume: false,
|
||||
canEnterWorld: true,
|
||||
};
|
||||
});
|
||||
|
||||
return [...draftItems, ...publishedItems].sort((left, right) =>
|
||||
right.updatedAt.localeCompare(left.updatedAt),
|
||||
|
||||
Reference in New Issue
Block a user