refactor: 收口推荐流展示模型
This commit is contained in:
@@ -359,6 +359,10 @@ import {
|
||||
isPersistedPuzzleDraftGenerating,
|
||||
resolvePuzzleWorkCoverImageSrc,
|
||||
} from '../custom-world-home/creationWorkShelf';
|
||||
import {
|
||||
buildPlatformRecommendFeedEntries,
|
||||
selectAdjacentPlatformRecommendEntry,
|
||||
} from '../rpg-entry/rpgEntryPublicGalleryViewModel';
|
||||
import {
|
||||
isBarkBattleGalleryEntry,
|
||||
isBigFishGalleryEntry,
|
||||
@@ -406,7 +410,6 @@ import {
|
||||
import {
|
||||
canExposePublicWork,
|
||||
EDUTAINMENT_HIDDEN_MESSAGE,
|
||||
filterGeneralPublicWorks,
|
||||
} from './platformEdutainmentVisibility';
|
||||
import { PlatformEntryCreationTypeModal } from './PlatformEntryCreationTypeModal';
|
||||
import type { PlatformCreationTypeId } from './platformEntryCreationTypes';
|
||||
@@ -5004,16 +5007,14 @@ export function PlatformEntryFlowShellImpl({
|
||||
woodenFishGalleryEntries,
|
||||
],
|
||||
);
|
||||
const recommendRuntimeEntries = useMemo(() => {
|
||||
const entryMap = new Map<string, PlatformPublicGalleryCard>();
|
||||
filterGeneralPublicWorks([
|
||||
...featuredGalleryEntries,
|
||||
...latestGalleryEntries,
|
||||
]).forEach((entry) => {
|
||||
entryMap.set(getPlatformPublicGalleryEntryKey(entry), entry);
|
||||
});
|
||||
return Array.from(entryMap.values());
|
||||
}, [featuredGalleryEntries, latestGalleryEntries]);
|
||||
const recommendRuntimeEntries = useMemo(
|
||||
() =>
|
||||
buildPlatformRecommendFeedEntries(
|
||||
featuredGalleryEntries,
|
||||
latestGalleryEntries,
|
||||
),
|
||||
[featuredGalleryEntries, latestGalleryEntries],
|
||||
);
|
||||
|
||||
const creationHubItems = useMemo<CustomWorldWorkSummary[]>(
|
||||
() =>
|
||||
@@ -14429,29 +14430,16 @@ export function PlatformEntryFlowShellImpl({
|
||||
);
|
||||
const selectAdjacentRecommendRuntimeEntry = useCallback(
|
||||
(direction: 1 | -1, baseEntryKey?: string | null) => {
|
||||
if (recommendRuntimeEntries.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const normalizedBaseEntryKey =
|
||||
baseEntryKey?.trim() || activeRecommendEntryKey;
|
||||
const activeIndex = recommendRuntimeEntries.findIndex(
|
||||
(entry) =>
|
||||
getPlatformPublicGalleryEntryKey(entry) === normalizedBaseEntryKey,
|
||||
const nextEntry = selectAdjacentPlatformRecommendEntry(
|
||||
recommendRuntimeEntries,
|
||||
direction,
|
||||
normalizedBaseEntryKey,
|
||||
);
|
||||
const baseIndex = activeIndex >= 0 ? activeIndex : 0;
|
||||
const nextIndex =
|
||||
(baseIndex + direction + recommendRuntimeEntries.length) %
|
||||
recommendRuntimeEntries.length;
|
||||
const nextEntry = recommendRuntimeEntries[nextIndex];
|
||||
if (!nextEntry) {
|
||||
return;
|
||||
}
|
||||
if (
|
||||
getPlatformPublicGalleryEntryKey(nextEntry) === normalizedBaseEntryKey
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
void selectRecommendRuntimeEntry(nextEntry);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user