Fix some issues with comment submission

- Fix error when submitting comments being ignored, meaning you'd only know if your comment got rejected if your comment wasn't there after the comments refreshed
- Fix issue in Request::ParseResponse where "Could not read response" is always included on all website errors
- Add ability to refresh comments by clicking the Submit button with an empty textbox
This commit is contained in:
jacob1
2024-05-14 23:56:58 -04:00
parent d32873b717
commit bb51daa05f
2 changed files with 13 additions and 5 deletions

View File

@@ -267,6 +267,7 @@ namespace http
{
std::istringstream ss(result);
Json::Value root;
int status;
try
{
ss >> root;
@@ -275,11 +276,7 @@ namespace http
{
return;
}
int status = root.get("Status", 1).asInt();
if (status != 1)
{
throw RequestError(ByteString(root.get("Error", "Unspecified Error").asString()));
}
status = root.get("Status", 1).asInt();
}
catch (const std::exception &ex)
{
@@ -291,6 +288,11 @@ namespace http
}
throw RequestError("Could not read response: " + ByteString(ex.what()));
}
if (status != 1)
{
throw RequestError(ByteString(root.get("Error", "Unspecified Error").asString()));
}
}
break;

View File

@@ -427,6 +427,7 @@ void PreviewView::OnTick(float dt)
{
try
{
addCommentRequest->Finish();
addCommentBox->SetText("");
c->CommentAdded();
}
@@ -600,6 +601,11 @@ void PreviewView::submitComment()
if (addCommentBox)
{
String comment = addCommentBox->GetText();
if (comment.length() == 0)
{
c->CommentAdded();
return;
}
if (comment.length() < 4)
{
new ErrorMessage("Error", "Comment is too short");