Skip to content

Commit

Permalink
AI Assistant: restrict stored state value (#34522)
Browse files Browse the repository at this point in the history
* restrict stored states to 'init' and 'done' so we don't reload into half way scenarios

* add changelog entry

* fix misuse of ternary
  • Loading branch information
CGastrell committed Dec 12, 2023
1 parent 59a2a1a commit a929801
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions projects/plugins/jetpack/changelog/fix-ai-state-stored-issue
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: bugfix

AI Assistant: restrict stored states to init and done to prevent half way states of the block
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,11 @@ export default function AIAssistantEdit( { attributes, setAttributes, clientId,
}, [ promptPlaceholder, currentIndex ] );

useEffect( () => {
// we don't want to store "half way" states
if ( ! [ 'init', 'done' ].includes( requestingState ) ) {
return;
}

setAttributes( { requestingState } );
}, [ requestingState, setAttributes ] );

Expand Down

0 comments on commit a929801

Please sign in to comment.