fix(chat): handle guest total limit
This commit is contained in:
@@ -103,7 +103,12 @@ export function applyHttpSendOutput(
|
||||
): Partial<ChatState> {
|
||||
const { response, reply } = output;
|
||||
|
||||
if (response.blocked === true && response.blockReason === "daily_limit") {
|
||||
const isMessageLimitBlocked =
|
||||
response.blocked === true &&
|
||||
(response.blockReason === "daily_limit" ||
|
||||
response.blockReason === "total_limit");
|
||||
|
||||
if (isMessageLimitBlocked) {
|
||||
const detail = response.blockDetail;
|
||||
const lastMessage = context.messages[context.messages.length - 1];
|
||||
const messages =
|
||||
@@ -115,9 +120,19 @@ export function applyHttpSendOutput(
|
||||
messages,
|
||||
isReplyingAI: false,
|
||||
paywallTriggered: true,
|
||||
paywallReason: "daily_limit",
|
||||
paywallReason:
|
||||
response.blockReason === "total_limit" ? "total_limit" : "daily_limit",
|
||||
paywallDetail: detail
|
||||
? { usedToday: detail.usedToday, limit: detail.limit }
|
||||
? {
|
||||
type: detail.type,
|
||||
...(detail.usedToday != null
|
||||
? { usedToday: detail.usedToday }
|
||||
: {}),
|
||||
...(detail.usedTotal != null
|
||||
? { usedTotal: detail.usedTotal }
|
||||
: {}),
|
||||
limit: detail.limit,
|
||||
}
|
||||
: null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -19,8 +19,20 @@ export interface ChatState {
|
||||
*/
|
||||
wsConnected: boolean;
|
||||
paywallTriggered: boolean;
|
||||
paywallReason: "daily_limit" | "photo_paywall" | "private_paywall" | null;
|
||||
paywallDetail: { usedToday: number; limit: number } | null;
|
||||
paywallReason:
|
||||
| "daily_limit"
|
||||
| "total_limit"
|
||||
| "photo_paywall"
|
||||
| "private_paywall"
|
||||
| null;
|
||||
paywallDetail:
|
||||
| {
|
||||
type?: string;
|
||||
usedToday?: number;
|
||||
usedTotal?: number;
|
||||
limit: number;
|
||||
}
|
||||
| null;
|
||||
unlockingPrivateMessageId: string | null;
|
||||
isLoadingMore: boolean;
|
||||
hasMore: boolean;
|
||||
|
||||
Reference in New Issue
Block a user