feat(chat): add support action cards and live entitlements
This commit is contained in:
@@ -14,6 +14,8 @@ import { AppEnvUtil } from "@/utils/app-env";
|
||||
import { Logger } from "@/utils/logger";
|
||||
import {
|
||||
CommercialActionSchema,
|
||||
ChatActionSchema,
|
||||
type ChatAction,
|
||||
type CommercialAction,
|
||||
} from "@/data/schemas/chat";
|
||||
|
||||
@@ -45,6 +47,7 @@ export class ChatWebSocket {
|
||||
onImage: ((url: string) => void) | null = null;
|
||||
onPaywallStatus: ((payload: PaywallStatusPayload) => void) | null = null;
|
||||
onCommercialAction: ((action: CommercialAction) => void) | null = null;
|
||||
onChatAction: ((action: ChatAction) => void) | null = null;
|
||||
onError: ((errorMessage: string) => void) | null = null;
|
||||
|
||||
constructor(
|
||||
@@ -151,6 +154,8 @@ export class ChatWebSocket {
|
||||
ctaLabel?: string;
|
||||
target?: string;
|
||||
ruleId?: string;
|
||||
kind?: string;
|
||||
orderId?: string | null;
|
||||
};
|
||||
};
|
||||
try {
|
||||
@@ -195,6 +200,11 @@ export class ChatWebSocket {
|
||||
if (action.success) this.onCommercialAction?.(action.data);
|
||||
break;
|
||||
}
|
||||
case "chat_action": {
|
||||
const action = ChatActionSchema.safeParse(payload.data);
|
||||
if (action.success) this.onChatAction?.(action.data);
|
||||
break;
|
||||
}
|
||||
case "error":
|
||||
this.onError?.(payload.error ?? "Unknown error");
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user