fix(chat): isolate pending flows and cancel stale requests
This commit is contained in:
@@ -15,6 +15,10 @@ import {
|
||||
savePendingChatPromotion,
|
||||
} from "@/lib/navigation/chat_unlock_session";
|
||||
import { ROUTES } from "@/router/routes";
|
||||
import {
|
||||
DEFAULT_CHARACTER_ID,
|
||||
getCharacterBySlug,
|
||||
} from "@/data/constants/character";
|
||||
import { Logger } from "@/utils/logger";
|
||||
import { useAuthDispatch, useAuthState } from "@/stores/auth/auth-context";
|
||||
|
||||
@@ -49,6 +53,8 @@ export default function ExternalEntryPersist({
|
||||
const hasReinitializedForPsidRef = useRef(false);
|
||||
const targetRoute = resolveExternalEntryTarget({ target });
|
||||
const destination = resolveExternalEntryDestination({ target, character });
|
||||
const characterId =
|
||||
getCharacterBySlug(character)?.id ?? DEFAULT_CHARACTER_ID;
|
||||
const resolvedPromotionType = resolveExternalEntryPromotionType({
|
||||
mode,
|
||||
promotionType,
|
||||
@@ -66,7 +72,7 @@ export default function ExternalEntryPersist({
|
||||
avatarUrl,
|
||||
}),
|
||||
targetRoute === ROUTES.chat && resolvedPromotionType
|
||||
? savePendingChatPromotion(resolvedPromotionType)
|
||||
? savePendingChatPromotion(resolvedPromotionType, characterId)
|
||||
: clearPendingChatPromotion(),
|
||||
]);
|
||||
for (const result of results) {
|
||||
@@ -87,6 +93,7 @@ export default function ExternalEntryPersist({
|
||||
avatarUrl,
|
||||
asid,
|
||||
character,
|
||||
characterId,
|
||||
destination,
|
||||
deviceId,
|
||||
mode,
|
||||
|
||||
Reference in New Issue
Block a user