Skip to content
Snippets Groups Projects

Issue # 3518940: Added a condition to check if the AI prompt is empty, and warns the user about it

Files
3
+ 8
0
@@ -33,6 +33,12 @@ function Edit({ attributes, setAttributes }) {
const [questionCopy, setQuestionCopy] = useState('');
const handleClick = () => {
/* title must not be empty of course */
if (title === undefined) {
setProcessingMessage('Please enter a valid question.');
return false;
}
/* Don't allow the user to click to request AI to answer the same question
* many times, this sends unnecessary requests and consume extra pennies
* that aren't needed */
@@ -40,6 +46,7 @@ function Edit({ attributes, setAttributes }) {
setProcessingMessage(
'You are asking the same question, please ask another question....',
);
return false;
}
@@ -64,6 +71,7 @@ function Edit({ attributes, setAttributes }) {
})
.then((response) => response.text())
.then((data) => {
console.log(data);
const parsedData = parseAIResponse(data);
setToken({ token: parsedData });
setAttributes({ aiAnswer: parsedData });
Loading