fix(chat): return directly to paid image
This commit is contained in:
@@ -8,7 +8,6 @@ import { useAuthState } from "@/stores/auth/auth-context";
|
|||||||
import { useChatDispatch, useChatState } from "@/stores/chat/chat-context";
|
import { useChatDispatch, useChatState } from "@/stores/chat/chat-context";
|
||||||
|
|
||||||
import { MobileShell } from "@/app/_components/core";
|
import { MobileShell } from "@/app/_components/core";
|
||||||
import { consumePendingChatImageReturn } from "./chat-image-return-session";
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
BrowserHintOverlay,
|
BrowserHintOverlay,
|
||||||
@@ -89,12 +88,6 @@ export function ChatScreen() {
|
|||||||
authState.loginStatus,
|
authState.loginStatus,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const pendingImageReturn = consumePendingChatImageReturn();
|
|
||||||
if (!pendingImageReturn) return;
|
|
||||||
router.replace(pendingImageReturn.returnUrl);
|
|
||||||
}, [router]);
|
|
||||||
|
|
||||||
async function handleOpenExternalBrowser(): Promise<void> {
|
async function handleOpenExternalBrowser(): Promise<void> {
|
||||||
setShowExternalBrowserDialog(false);
|
setShowExternalBrowserDialog(false);
|
||||||
await openChatInExternalBrowser();
|
await openChatInExternalBrowser();
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { useEffect, useMemo, useRef, useState } from "react";
|
|||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
|
|
||||||
import { BackButton } from "@/app/_components";
|
import { BackButton } from "@/app/_components";
|
||||||
|
import { consumePendingChatImageReturn } from "@/app/chat/chat-image-return-session";
|
||||||
import { Checkbox, MobileShell } from "@/app/_components/core";
|
import { Checkbox, MobileShell } from "@/app/_components/core";
|
||||||
import { AppConstants } from "@/core/app_constants";
|
import { AppConstants } from "@/core/app_constants";
|
||||||
import { PendingPaymentOrderStorage } from "@/data/storage";
|
import { PendingPaymentOrderStorage } from "@/data/storage";
|
||||||
@@ -157,11 +158,28 @@ export function SubscriptionScreen({
|
|||||||
payment.isPollingOrder;
|
payment.isPollingOrder;
|
||||||
const canActivate =
|
const canActivate =
|
||||||
selectedPlan !== null && payment.agreed && !isPaymentBusy;
|
selectedPlan !== null && payment.agreed && !isPaymentBusy;
|
||||||
const backHref = returnTo === "chat" ? ROUTES.chat : ROUTES.sidebar;
|
|
||||||
|
const consumeSubscriptionExitUrl = (): string | null => {
|
||||||
|
const pendingImageReturn = consumePendingChatImageReturn();
|
||||||
|
if (pendingImageReturn) return pendingImageReturn.returnUrl;
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleBackClick = () => {
|
||||||
|
router.replace(
|
||||||
|
consumeSubscriptionExitUrl() ??
|
||||||
|
(returnTo === "chat" ? ROUTES.chat : ROUTES.sidebar),
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const finishPaymentSuccessClose = () => {
|
const finishPaymentSuccessClose = () => {
|
||||||
setShowPaymentSuccessDialog(false);
|
setShowPaymentSuccessDialog(false);
|
||||||
paymentDispatch({ type: "PaymentReset" });
|
paymentDispatch({ type: "PaymentReset" });
|
||||||
|
const pendingExitUrl = consumeSubscriptionExitUrl();
|
||||||
|
if (pendingExitUrl) {
|
||||||
|
router.replace(pendingExitUrl);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (returnTo === "chat") {
|
if (returnTo === "chat") {
|
||||||
router.replace(ROUTES.chat);
|
router.replace(ROUTES.chat);
|
||||||
}
|
}
|
||||||
@@ -219,7 +237,7 @@ export function SubscriptionScreen({
|
|||||||
<header className={styles.header}>
|
<header className={styles.header}>
|
||||||
<BackButton
|
<BackButton
|
||||||
className={styles.backSlot}
|
className={styles.backSlot}
|
||||||
href={backHref}
|
onClick={handleBackClick}
|
||||||
variant="soft"
|
variant="soft"
|
||||||
/>
|
/>
|
||||||
</header>
|
</header>
|
||||||
|
|||||||
Reference in New Issue
Block a user