Files
cozsweet-frontend-nextjs/src/lib/navigation/chat_unlock_session.ts
T
admin 25da9262a0
Docker Image / Quality and Bundle Budgets (push) Successful in 3s
Docker Image / Build and Push Docker Image (push) Has been cancelled
feat(chat): add composer action menu
2026-07-21 18:45:25 +08:00

86 lines
2.4 KiB
TypeScript

"use client";
import {
createPendingChatPromotion as createPromotion,
NavigationStorage,
type PendingChatUnlock,
type PendingChatUnlockKind,
type PendingChatPromotion,
type PendingChatPromotionType,
type PendingChatUnlockStage,
} from "@/data/storage/navigation";
export type {
PendingChatUnlock,
PendingChatUnlockKind,
PendingChatPromotion,
PendingChatPromotionType,
PendingChatUnlockStage,
};
export function createPendingChatPromotion(
promotionType: PendingChatPromotionType,
characterId: string,
): PendingChatPromotion {
return createPromotion(promotionType, characterId);
}
export async function savePendingChatUnlock(input: {
characterId: string;
displayMessageId?: string;
messageId?: string;
kind: PendingChatUnlockKind;
lockType?: PendingChatUnlock["lockType"];
clientLockId?: string;
promotion?: PendingChatPromotion;
returnUrl: string;
stage: PendingChatUnlockStage;
}): Promise<void> {
await NavigationStorage.savePendingChatUnlock(input);
}
export async function consumePendingChatUnlock(
characterId: string,
): Promise<PendingChatUnlock | null> {
return NavigationStorage.consumePendingChatUnlock(characterId);
}
export async function peekPendingChatUnlock(
characterId: string,
): Promise<PendingChatUnlock | null> {
return NavigationStorage.peekPendingChatUnlock(characterId);
}
export async function hasPendingChatUnlock(characterId: string): Promise<boolean> {
return NavigationStorage.hasPendingChatUnlock(characterId);
}
export async function clearPendingChatUnlock(): Promise<void> {
await NavigationStorage.clearPendingChatUnlock();
}
export async function savePendingChatPromotion(
promotionType: PendingChatPromotionType,
characterId: string,
): Promise<PendingChatPromotion> {
return NavigationStorage.savePendingChatPromotion(promotionType, characterId);
}
export async function consumePendingChatPromotion(
characterId: string,
): Promise<PendingChatPromotion | null> {
return NavigationStorage.consumePendingChatPromotion(characterId);
}
export async function clearPendingChatPromotion(): Promise<void> {
await NavigationStorage.clearPendingChatPromotion();
}
export async function clearPendingChatNavigation(): Promise<void> {
await Promise.all([
NavigationStorage.clearPendingChatUnlock(),
NavigationStorage.clearPendingChatPromotion(),
NavigationStorage.clearPendingChatImageReturn(),
]);
}