refactor: 收口创作直达恢复判定
This commit is contained in:
@@ -6,7 +6,10 @@ import type { PuzzleAgentSessionSnapshot } from '../../../packages/shared/src/co
|
||||
import type { PuzzleWorkSummary } from '../../../packages/shared/src/contracts/puzzleWorkSummary';
|
||||
import type { SquareHoleSessionSnapshot } from '../../../packages/shared/src/contracts/squareHoleAgent';
|
||||
import type { VisualNovelAgentSessionSnapshot } from '../../../packages/shared/src/contracts/visualNovel';
|
||||
import type { CreationUrlState } from '../../services/creationUrlState';
|
||||
import {
|
||||
type CreationUrlState,
|
||||
isCreationRestorePath,
|
||||
} from '../../services/creationUrlState';
|
||||
import type {
|
||||
JumpHopSessionSnapshotResponse,
|
||||
JumpHopWorkProfileResponse,
|
||||
@@ -57,6 +60,37 @@ export function buildPuzzleRuntimeUrlStateKey(state: PuzzleRuntimeUrlState) {
|
||||
].join('|');
|
||||
}
|
||||
|
||||
export type InitialCreationUrlRestoreDecision =
|
||||
| { type: 'skip' }
|
||||
| { type: 'mark-handled' }
|
||||
| { type: 'wait' }
|
||||
| { type: 'restore' };
|
||||
|
||||
export function resolveInitialCreationUrlRestoreDecision(params: {
|
||||
handled: boolean;
|
||||
pathname: string | undefined;
|
||||
state: CreationUrlState;
|
||||
isLoadingPlatform: boolean;
|
||||
canReadProtectedData: boolean;
|
||||
}): InitialCreationUrlRestoreDecision {
|
||||
if (params.handled) {
|
||||
return { type: 'skip' };
|
||||
}
|
||||
|
||||
if (
|
||||
!isCreationRestorePath(params.pathname) ||
|
||||
!hasCreationUrlStateValue(params.state)
|
||||
) {
|
||||
return { type: 'mark-handled' };
|
||||
}
|
||||
|
||||
if (params.isLoadingPlatform || !params.canReadProtectedData) {
|
||||
return { type: 'wait' };
|
||||
}
|
||||
|
||||
return { type: 'restore' };
|
||||
}
|
||||
|
||||
export function buildBigFishCreationUrlState(
|
||||
session: BigFishSessionSnapshotResponse | null,
|
||||
): CreationUrlState {
|
||||
|
||||
Reference in New Issue
Block a user