refactor(chat): rely on server message limits
This commit is contained in:
@@ -42,22 +42,14 @@ export function ChatScreen() {
|
||||
// isGuest 派生(chat-screen 是唯一知道这个值的地方 —— chat 机器无 isGuest 字段)
|
||||
const isGuest = deriveIsGuest(authState.loginStatus);
|
||||
|
||||
// 游客配额耗尽 → 显示 Unlock CTA banner(替代 ChatInputBar)
|
||||
// 三重条件:游客 + 配额加载完 + 用户被配额 guard 拦截过至少一次
|
||||
// - quotaLoaded 避免一进 /chat 就跳 banner(loadQuota 还在 in-flight)
|
||||
// - quotaExceededTrigger 而非 guestTotalQuota / guestRemainingQuota ——
|
||||
// trigger 由 chat 机器的 guard 在 ChatSendMessage / ChatSendImage 被拦截时 +1,
|
||||
// 是 "用户被配额拒绝过" 的权威信号(避免依赖 quota 数值本身的边界判断)
|
||||
const showGuestQuotaBanner =
|
||||
isGuest && state.quotaLoaded && state.quotaExceededTrigger > 0;
|
||||
// 消息数量限制由后端统一返回 blocked/daily_limit,前端不再处理本地额度。
|
||||
const showDailyLimitBanner =
|
||||
!isGuest &&
|
||||
state.paywallTriggered &&
|
||||
state.paywallReason === "daily_limit";
|
||||
const showPhotoPaywallBanner =
|
||||
state.paywallTriggered && state.paywallReason === "photo_paywall";
|
||||
const showExhaustedBanner =
|
||||
showGuestQuotaBanner || showDailyLimitBanner || showPhotoPaywallBanner;
|
||||
showDailyLimitBanner || showPhotoPaywallBanner;
|
||||
|
||||
const externalBrowserPromptShownRef = useRef(false);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user