-
Notifications
You must be signed in to change notification settings - Fork 10.7k
/
actions.ts
35 lines (31 loc) · 1.15 KB
/
actions.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
* External dependencies
*/
import { sendParent } from 'xstate';
/**
* Internal dependencies
*/
import { DesignWithoutAIStateMachineContext } from './types';
import { DesignWithoutAIStateMachineEvents } from './state-machine';
const redirectToAssemblerHub = async () => {
// This is a workaround to update the "activeThemeHasMods" in the parent's machine
// state context. We should find a better way to do this using xstate actions,
// since state machines should rely only on their context.
// Will be fixed on: https://github.com/woocommerce/woocommerce/issues/44349
// This is needed because the iframe loads the entire Customize Store app.
// This means that the iframe instance will have different state machines
// than the parent window.
// Check https://github.com/woocommerce/woocommerce/pull/44206 for more details.
window.parent.__wcCustomizeStore.activeThemeHasMods = true;
};
const redirectToIntroWithError = sendParent<
DesignWithoutAIStateMachineContext,
DesignWithoutAIStateMachineEvents,
DesignWithoutAIStateMachineEvents
>( {
type: 'NO_AI_FLOW_ERROR',
} );
export const actions = {
redirectToAssemblerHub,
redirectToIntroWithError,
};