Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
097ab96
[not verified] first try
millerf Jan 20, 2023
5d6d3ad
changelog
millerf Jan 20, 2023
0b8fc57
Some cleanup, add retry button
millerf Jan 20, 2023
a0a095f
Some fix
millerf Jan 20, 2023
ca3fc4b
Some re-work
millerf Jan 20, 2023
ebe2ab9
More fixes
millerf Jan 20, 2023
d16bb2a
Refactor logic
millerf Jan 20, 2023
69828a5
Refactor logic
millerf Jan 20, 2023
e3977f2
Add animated text
millerf Jan 20, 2023
cdcafc0
Fix issue when not enough characters are needed
millerf Jan 20, 2023
f980993
Use closures for createPrompt
millerf Jan 23, 2023
e99b74e
Rename state attributes that could be misleading
millerf Jan 23, 2023
f3b7410
Make containsAiUntriggeredParapgraph more readable
millerf Jan 23, 2023
a6869f8
Remove useless/wrong comment
millerf Jan 23, 2023
0cac4b1
[not verified] implement Brent's feedback
millerf Jan 23, 2023
58c3d15
added useSelect dependencies
millerf Jan 23, 2023
ee0e586
Some fixes
millerf Jan 23, 2023
7c4bd92
Small fixes
millerf Jan 23, 2023
153016b
Merge branch 'trunk' into add/open-ai-useselect
millerf Jan 23, 2023
5d5d779
Better wording for ShowLittleByLittle state vars
millerf Jan 23, 2023
a82a030
Fix typo
millerf Jan 23, 2023
d9ea9f4
Fix issue when switching order
millerf Jan 23, 2023
9e348e5
Check length for the title
millerf Jan 23, 2023
e5614d6
Added comment
millerf Jan 23, 2023
a9025a0
Should display retry when the API errors
millerf Jan 23, 2023
1417e93
Save line breaks as <br/>
millerf Jan 23, 2023
1ebe175
Remove isContentSet and use useEffect instead
millerf Jan 24, 2023
4c9a257
Save animationDone in the component data to prevent redrawing issues …
millerf Jan 24, 2023
3b60c88
Use block name from index.js
millerf Jan 24, 2023
688ce57
Transform to <br/> on setting the content
millerf Jan 24, 2023
cf95859
Merge branch 'trunk' into add/open-ai-useselect
millerf Jan 24, 2023
8b55682
[not verified] apply nl2br at the end of the process as content is be…
millerf Jan 24, 2023
3124f5c
Fix issue when there is no content
millerf Jan 24, 2023
816d315
set content as HTML source and do the nl2br whenr eceiving the data
millerf Jan 24, 2023
11d360f
escape br
artpi Jan 24, 2023
e14b3bc
Merge branch 'trunk' into add/open-ai-useselect
millerf Jan 24, 2023
f31e910
restart tests
millerf Jan 24, 2023
c86eee2
Romario's feedback
millerf Jan 25, 2023
19b7ec9
Pleasing the crowd
millerf Jan 25, 2023
a687cd8
relaunch tests
millerf Jan 25, 2023
620824a
Merge branch 'trunk' into add/open-ai-useselect
artpi Jan 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix issue when not enough characters are needed
  • Loading branch information
millerf committed Jan 20, 2023
commit cdcafc0a0151fedbc655dcbe652a973e2f00002b
13 changes: 8 additions & 5 deletions projects/plugins/jetpack/extensions/blocks/ai-paragraph/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export default function Edit( { attributes, setAttributes, clientId } ) {

// Waiting state means there is nothing to be done until it resolves
const waitingState = completionFinished || loadingCompletion || loadingCategories;

const nbCharactersNeeded = numberOfCharactersNeeded - content.length;
if ( ! waitingState ) {
if ( containsAiUntriggeredParapgraph( contentBefore ) ) {
if ( ! errorMessage ) {
Expand All @@ -214,26 +214,29 @@ export default function Edit( { attributes, setAttributes, clientId } ) {
__( 'Waiting for the previous AI paragraph block to finish', 'jetpack' )
);
}
} else if ( content.length < numberOfCharactersNeeded && needsMoreCharacters === 0 ) {
} else if (
content.length < numberOfCharactersNeeded &&
needsMoreCharacters !== nbCharactersNeeded
) {
setErrorMessage(
sprintf(
/** translators: First placeholder is a number of more characters we need */
__(
'Please write a longer title or a few more words in the opening preceding the AI block. Our AI model needs %1$d more characters.',
'jetpack'
),
numberOfCharactersNeeded - content.length
nbCharactersNeeded
)
);
setNeedsMoreCharacters( numberOfCharactersNeeded - content.length );
setNeedsMoreCharacters( nbCharactersNeeded );
} else if ( needsMoreCharacters !== 0 && content.length >= numberOfCharactersNeeded ) {
setErrorMessage(
/** translators: This is to retry to complete the text */
__( 'Ready to retry', 'jetpack' )
);
setShowRetry( true );
setNeedsMoreCharacters( 0 );
} else {
} else if ( needsMoreCharacters === 0 && ! showRetry ) {
getSuggestionFromOpenAI();
}
}
Expand Down