From bb51daa05f8ad468ed1328a4a57cf28a589ab419 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Tue, 14 May 2024 23:56:58 -0400 Subject: [PATCH] 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 --- src/client/http/Request.cpp | 12 +++++++----- src/gui/preview/PreviewView.cpp | 6 ++++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/client/http/Request.cpp b/src/client/http/Request.cpp index c4f7e4679..e27291ef5 100644 --- a/src/client/http/Request.cpp +++ b/src/client/http/Request.cpp @@ -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; diff --git a/src/gui/preview/PreviewView.cpp b/src/gui/preview/PreviewView.cpp index 50ed635f0..66d237a34 100644 --- a/src/gui/preview/PreviewView.cpp +++ b/src/gui/preview/PreviewView.cpp @@ -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");