feat(payment): add chat support discounts and gratitude
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { createChatPromotionState } from "../helper/promotion";
|
||||
import { appendCommercialMessage } from "../helper/commercial-message";
|
||||
import { shouldPromptUnlockHistory } from "../helper/unlock";
|
||||
import { createInitialChatState } from "../chat-state";
|
||||
import {
|
||||
@@ -53,6 +54,19 @@ const injectPromotionAction = unlockMachineSetup.assign(({ event }) => {
|
||||
|
||||
const clearPromotionAction = unlockMachineSetup.assign({ promotion: null });
|
||||
|
||||
const appendCommercialMessageAction = unlockMachineSetup.assign(
|
||||
({ context, event }) => {
|
||||
if (event.type !== "ChatCommercialMessageReceived") return {};
|
||||
return {
|
||||
messages: appendCommercialMessage(
|
||||
context.messages,
|
||||
context.characterId,
|
||||
event.message,
|
||||
),
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
export const chatMachineSetup = unlockMachineSetup.extend({
|
||||
actions: {
|
||||
startGuestSession: startGuestSessionAction,
|
||||
@@ -60,6 +74,7 @@ export const chatMachineSetup = unlockMachineSetup.extend({
|
||||
clearChatSession: clearChatSessionAction,
|
||||
injectPromotion: injectPromotionAction,
|
||||
clearPromotion: clearPromotionAction,
|
||||
appendCommercialMessage: appendCommercialMessageAction,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -258,6 +273,7 @@ export const chatRootStateConfig = chatMachineSetup.createStateConfig({
|
||||
on: {
|
||||
ChatPromotionInjected: { actions: "injectPromotion" },
|
||||
ChatPromotionCleared: { actions: "clearPromotion" },
|
||||
ChatCommercialMessageReceived: { actions: "appendCommercialMessage" },
|
||||
},
|
||||
states: {
|
||||
idle: idleState,
|
||||
|
||||
Reference in New Issue
Block a user