fix(chat): unify insufficient credits prompt
This commit is contained in:
@@ -2,9 +2,7 @@
|
||||
|
||||
import { useEffect, useRef } from "react";
|
||||
|
||||
import type { LoginStatus } from "@/data/dto/auth";
|
||||
import { behaviorAnalytics } from "@/lib/analytics";
|
||||
import { ROUTES } from "@/router/routes";
|
||||
import { useAppNavigator } from "@/router/use-app-navigator";
|
||||
import type { ChatUpgradeReason } from "@/stores/chat/chat-state";
|
||||
import { useUserSelector } from "@/stores/user/user-context";
|
||||
@@ -19,7 +17,6 @@ import {
|
||||
export interface UseChatMessageLimitBannerInput {
|
||||
upgradePromptVisible: boolean;
|
||||
upgradeReason: ChatUpgradeReason | null;
|
||||
loginStatus: LoginStatus;
|
||||
}
|
||||
|
||||
export interface ChatMessageLimitBannerView
|
||||
@@ -31,11 +28,10 @@ export interface ChatMessageLimitBannerView
|
||||
export function useChatMessageLimitBanner({
|
||||
upgradePromptVisible,
|
||||
upgradeReason,
|
||||
loginStatus,
|
||||
}: UseChatMessageLimitBannerInput): ChatMessageLimitBannerView {
|
||||
const navigator = useAppNavigator();
|
||||
const isVip = useUserSelector((state) => state.context.isVip);
|
||||
const view = getInsufficientCreditsMessageLimitView(loginStatus);
|
||||
const view = getInsufficientCreditsMessageLimitView();
|
||||
const visible = shouldShowMessageLimitBanner({
|
||||
upgradePromptVisible,
|
||||
upgradeReason,
|
||||
@@ -59,11 +55,6 @@ export function useChatMessageLimitBanner({
|
||||
}, [isVip, visible]);
|
||||
|
||||
function unlock(): void {
|
||||
if (view.action === "auth") {
|
||||
navigator.openAuth(ROUTES.chat);
|
||||
return;
|
||||
}
|
||||
|
||||
navigator.openSubscription({
|
||||
type: getInsufficientCreditsSubscriptionType(isVip),
|
||||
returnTo: "chat",
|
||||
|
||||
Reference in New Issue
Block a user