2024-01-11 14:32:16 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
2024-01-25 11:04:44 +00:00
|
|
|
import { sendParent } from 'xstate';
|
|
|
|
|
2024-01-11 14:32:16 +00:00
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
2024-01-25 11:04:44 +00:00
|
|
|
import { DesignWithoutAIStateMachineContext } from './types';
|
|
|
|
import { DesignWithoutAIStateMachineEvents } from './state-machine';
|
2024-01-11 14:32:16 +00:00
|
|
|
|
|
|
|
const redirectToAssemblerHub = async () => {
|
2024-02-05 11:36:33 +00:00
|
|
|
// 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;
|
2024-01-11 14:32:16 +00:00
|
|
|
};
|
|
|
|
|
2024-01-25 11:04:44 +00:00
|
|
|
const redirectToIntroWithError = sendParent<
|
|
|
|
DesignWithoutAIStateMachineContext,
|
|
|
|
DesignWithoutAIStateMachineEvents,
|
|
|
|
DesignWithoutAIStateMachineEvents
|
|
|
|
>( {
|
|
|
|
type: 'NO_AI_FLOW_ERROR',
|
|
|
|
} );
|
|
|
|
|
2024-01-11 14:32:16 +00:00
|
|
|
export const actions = {
|
|
|
|
redirectToAssemblerHub,
|
2024-01-25 11:04:44 +00:00
|
|
|
redirectToIntroWithError,
|
2024-01-11 14:32:16 +00:00
|
|
|
};
|