Skip to content

Commit

Permalink
Fix some issues with comment submission
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
jacob1 committed May 15, 2024
1 parent d32873b commit bb51daa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/client/http/Request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ namespace http
{
std::istringstream ss(result);
Json::Value root;
int status;
try
{
ss >> root;
Expand All @@ -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)
{
Expand All @@ -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;

Expand Down
6 changes: 6 additions & 0 deletions src/gui/preview/PreviewView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ void PreviewView::OnTick(float dt)
{
try
{
addCommentRequest->Finish();
addCommentBox->SetText("");
c->CommentAdded();
}
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit bb51daa

Please sign in to comment.