refactor: 补齐草稿与SSE收口
This commit is contained in:
@@ -439,7 +439,6 @@ import {
|
||||
type DraftGenerationNoticeMap,
|
||||
type DraftGenerationNoticeStatus,
|
||||
getGenerationNoticeShelfKeys,
|
||||
hasDraftGenerationNoticeStatus,
|
||||
hasUnreadDraftGenerationUpdates,
|
||||
mergeBigFishWorkSummary,
|
||||
mergePuzzleWorkSummary,
|
||||
@@ -448,10 +447,12 @@ import {
|
||||
type PendingDraftShelfMap,
|
||||
type PendingDraftShelfMetadata,
|
||||
resolveBigFishDraftOpenIntent,
|
||||
resolveJumpHopDraftOpenIntent,
|
||||
resolveMatch3DDraftOpenIntent,
|
||||
resolvePuzzleDraftOpenIntent,
|
||||
resolveSquareHoleDraftOpenIntent,
|
||||
resolveVisualNovelDraftOpenIntent,
|
||||
resolveWoodenFishDraftOpenIntent,
|
||||
} from './platformDraftGenerationShelfModel';
|
||||
import {
|
||||
canExposePublicWork,
|
||||
@@ -2010,11 +2011,6 @@ export function PlatformEntryFlowShellImpl({
|
||||
activePuzzleGenerationSessionIdRef.current === sessionId
|
||||
);
|
||||
}, []);
|
||||
const isDraftNoticeFailed = useCallback(
|
||||
(kind: CreationWorkShelfKind, ids: Array<string | null | undefined>) =>
|
||||
hasDraftGenerationNoticeStatus(draftGenerationNotices, kind, ids, 'failed'),
|
||||
[draftGenerationNotices],
|
||||
);
|
||||
const ensureEnoughDraftGenerationPointsFromServer = useCallback(
|
||||
async (pointsCost: number) => {
|
||||
try {
|
||||
@@ -9920,12 +9916,17 @@ export function PlatformEntryFlowShellImpl({
|
||||
|
||||
const openJumpHopDraft = useCallback(
|
||||
async (item: JumpHopWorkSummaryResponse) => {
|
||||
const noticeIds = [item.workId, item.profileId, item.sourceSessionId];
|
||||
const hasFailedNotice = isDraftNoticeFailed('jump-hop', noticeIds);
|
||||
const sessionId = normalizeCreationUrlValue(item.sourceSessionId);
|
||||
markDraftNoticeSeen(collectDraftNoticeKeys('jump-hop', noticeIds));
|
||||
const openIntent = resolveJumpHopDraftOpenIntent({
|
||||
item,
|
||||
notices: draftGenerationNotices,
|
||||
generation: {
|
||||
activeSessionId: jumpHopSession?.sessionId,
|
||||
hasActiveGenerationFailure: jumpHopGenerationState?.phase === 'failed',
|
||||
},
|
||||
});
|
||||
markDraftNoticeSeen(openIntent.noticeKeys);
|
||||
|
||||
if (item.publicationStatus === 'published') {
|
||||
if (openIntent.type === 'open-published-detail') {
|
||||
void openJumpHopPublicWorkDetail(item.profileId);
|
||||
return;
|
||||
}
|
||||
@@ -9933,18 +9934,14 @@ export function PlatformEntryFlowShellImpl({
|
||||
setJumpHopError(null);
|
||||
setPublicWorkDetailError(null);
|
||||
setIsJumpHopBusy(true);
|
||||
if (
|
||||
hasFailedNotice &&
|
||||
sessionId === jumpHopSession?.sessionId &&
|
||||
jumpHopGenerationState?.phase === 'failed'
|
||||
) {
|
||||
if (openIntent.type === 'active-failed-generation') {
|
||||
enterCreateTab();
|
||||
setSelectionStage('jump-hop-generating');
|
||||
setIsJumpHopBusy(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.generationStatus === 'generating' && !hasFailedNotice) {
|
||||
if (openIntent.type === 'restore-generating') {
|
||||
const pendingSession = buildJumpHopPendingSession(item);
|
||||
setJumpHopSession(pendingSession);
|
||||
setJumpHopRun(null);
|
||||
@@ -9981,8 +9978,8 @@ export function PlatformEntryFlowShellImpl({
|
||||
}
|
||||
},
|
||||
[
|
||||
draftGenerationNotices,
|
||||
enterCreateTab,
|
||||
isDraftNoticeFailed,
|
||||
jumpHopGenerationState?.phase,
|
||||
jumpHopSession?.sessionId,
|
||||
markDraftNoticeSeen,
|
||||
@@ -10016,13 +10013,18 @@ export function PlatformEntryFlowShellImpl({
|
||||
|
||||
const openWoodenFishDraft = useCallback(
|
||||
async (item: WoodenFishWorkSummaryResponse) => {
|
||||
const noticeIds = [item.workId, item.profileId, item.sourceSessionId];
|
||||
const hasFailedNotice = isDraftNoticeFailed('wooden-fish', noticeIds);
|
||||
const sessionId =
|
||||
normalizeCreationUrlValue(item.sourceSessionId) ?? item.profileId;
|
||||
markDraftNoticeSeen(collectDraftNoticeKeys('wooden-fish', noticeIds));
|
||||
const openIntent = resolveWoodenFishDraftOpenIntent({
|
||||
item,
|
||||
notices: draftGenerationNotices,
|
||||
generation: {
|
||||
activeSessionId: woodenFishSession?.sessionId,
|
||||
hasActiveGenerationFailure:
|
||||
woodenFishGenerationState?.phase === 'failed',
|
||||
},
|
||||
});
|
||||
markDraftNoticeSeen(openIntent.noticeKeys);
|
||||
|
||||
if (item.publicationStatus === 'published') {
|
||||
if (openIntent.type === 'open-published-detail') {
|
||||
void openWoodenFishPublicWorkDetail(item.profileId);
|
||||
return;
|
||||
}
|
||||
@@ -10030,18 +10032,14 @@ export function PlatformEntryFlowShellImpl({
|
||||
setWoodenFishError(null);
|
||||
setPublicWorkDetailError(null);
|
||||
setIsWoodenFishBusy(true);
|
||||
if (
|
||||
hasFailedNotice &&
|
||||
sessionId === woodenFishSession?.sessionId &&
|
||||
woodenFishGenerationState?.phase === 'failed'
|
||||
) {
|
||||
if (openIntent.type === 'active-failed-generation') {
|
||||
enterCreateTab();
|
||||
setSelectionStage('wooden-fish-generating');
|
||||
setIsWoodenFishBusy(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.generationStatus === 'generating' && !hasFailedNotice) {
|
||||
if (openIntent.type === 'restore-generating') {
|
||||
const pendingSession = buildWoodenFishPendingSession(item);
|
||||
setWoodenFishSession(pendingSession);
|
||||
setWoodenFishRun(null);
|
||||
@@ -10083,16 +10081,14 @@ export function PlatformEntryFlowShellImpl({
|
||||
resolveRpgCreationErrorMessage(error, '读取敲木鱼草稿失败。'),
|
||||
);
|
||||
enterCreateTab();
|
||||
setSelectionStage(
|
||||
hasFailedNotice ? 'wooden-fish-workspace' : 'wooden-fish-generating',
|
||||
);
|
||||
setSelectionStage(openIntent.failureFallbackStage);
|
||||
} finally {
|
||||
setIsWoodenFishBusy(false);
|
||||
}
|
||||
},
|
||||
[
|
||||
draftGenerationNotices,
|
||||
enterCreateTab,
|
||||
isDraftNoticeFailed,
|
||||
markDraftNoticeSeen,
|
||||
openWoodenFishPublicWorkDetail,
|
||||
woodenFishGenerationState?.phase,
|
||||
|
||||
Reference in New Issue
Block a user