CYS: Reset products when the AI is offline (#41923)

* CYS: Reset products when the AI is offline

* Add changefile(s) from automation for the following project(s): woocommerce

---------

Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
Luigi Teschio 2023-12-07 09:42:16 +01:00 committed by GitHub
parent 01d9bfc678
commit f59b95d6e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 9 deletions

View File

@ -473,15 +473,21 @@ const saveAiResponseToOption = ( context: designWithAiStateMachineContext ) => {
} );
};
const resetPatterns = () => async () => {
const resetPatternsAndProducts = () => async () => {
await dispatch( OPTIONS_STORE_NAME ).updateOptions( {
woocommerce_blocks_allow_ai_connection: 'yes',
} );
return await apiFetch( {
path: '/wc/private/ai/patterns',
method: 'DELETE',
} );
return Promise.all( [
apiFetch( {
path: '/wc/private/ai/patterns',
method: 'DELETE',
} ),
apiFetch( {
path: '/wc/private/ai/products',
method: 'DELETE',
} ),
] );
};
export const services = {
@ -491,5 +497,5 @@ export const services = {
updateStorePatterns,
saveAiResponseToOption,
installAndActivateTheme,
resetPatterns,
resetPatternsAndProducts,
};

View File

@ -355,7 +355,7 @@ export const designWithAiStateMachineDefinition = createMachine(
cond: 'isAiOnline',
},
{
target: 'resetPatterns',
target: 'resetPatternsAndProducts',
},
],
},
@ -373,9 +373,9 @@ export const designWithAiStateMachineDefinition = createMachine(
},
},
},
resetPatterns: {
resetPatternsAndProducts: {
invoke: {
src: 'resetPatterns',
src: 'resetPatternsAndProducts',
onDone: {
target: 'success',
},

View File

@ -0,0 +1,4 @@
Significance: minor
Type: update
CYS: Reset products when the AI is offline.