feat(chat): sync multi-role backend APIs
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
||||
import type { UnlockHistoryOutput } from "./actors/unlock";
|
||||
import { sendMachineSetup } from "./send-flow";
|
||||
import { createChatActorActionSetup } from "./setup";
|
||||
import { getCharacterErrorCode } from "@/data/services/api";
|
||||
|
||||
const markPaymentUnlockPendingAction = sendMachineSetup.assign(() => ({
|
||||
paymentUnlockPending: true,
|
||||
@@ -146,6 +147,13 @@ const clearUnlockPaywallRequestAction = sendMachineSetup.assign(() => ({
|
||||
unlockPaywallRequest: null,
|
||||
}));
|
||||
|
||||
const handleCharacterMismatchAction = sendMachineSetup.assign(() => ({
|
||||
unlockingMessage: null,
|
||||
unlockMessageError: "character_mismatch",
|
||||
unlockPaywallRequest: null,
|
||||
characterErrorCode: "CHARACTER_MISMATCH" as const,
|
||||
}));
|
||||
|
||||
export const unlockMachineSetup = sendMachineSetup.extend({
|
||||
actions: {
|
||||
markPaymentUnlockPending: markPaymentUnlockPendingAction,
|
||||
@@ -158,6 +166,7 @@ export const unlockMachineSetup = sendMachineSetup.extend({
|
||||
requestUnlockPaymentFromOutput: requestUnlockPaymentFromOutputAction,
|
||||
requestUnlockPaymentFromError: requestUnlockPaymentFromErrorAction,
|
||||
clearUnlockPaywallRequest: clearUnlockPaywallRequestAction,
|
||||
handleCharacterMismatch: handleCharacterMismatchAction,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -225,9 +234,17 @@ export const unlockingMessageState = unlockMachineSetup.createStateConfig({
|
||||
actions: "requestUnlockPaymentFromOutput",
|
||||
},
|
||||
],
|
||||
onError: {
|
||||
target: "ready",
|
||||
actions: "requestUnlockPaymentFromError",
|
||||
},
|
||||
onError: [
|
||||
{
|
||||
guard: ({ event }) =>
|
||||
getCharacterErrorCode(event.error) === "CHARACTER_MISMATCH",
|
||||
target: "ready",
|
||||
actions: "handleCharacterMismatch",
|
||||
},
|
||||
{
|
||||
target: "ready",
|
||||
actions: "requestUnlockPaymentFromError",
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user