mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-30 11:19:51 +02:00
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:
@@ -267,6 +267,7 @@ namespace http
|
|||||||
{
|
{
|
||||||
std::istringstream ss(result);
|
std::istringstream ss(result);
|
||||||
Json::Value root;
|
Json::Value root;
|
||||||
|
int status;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ss >> root;
|
ss >> root;
|
||||||
@@ -275,11 +276,7 @@ namespace http
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int status = root.get("Status", 1).asInt();
|
status = root.get("Status", 1).asInt();
|
||||||
if (status != 1)
|
|
||||||
{
|
|
||||||
throw RequestError(ByteString(root.get("Error", "Unspecified Error").asString()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (const std::exception &ex)
|
catch (const std::exception &ex)
|
||||||
{
|
{
|
||||||
@@ -291,6 +288,11 @@ namespace http
|
|||||||
}
|
}
|
||||||
throw RequestError("Could not read response: " + ByteString(ex.what()));
|
throw RequestError("Could not read response: " + ByteString(ex.what()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (status != 1)
|
||||||
|
{
|
||||||
|
throw RequestError(ByteString(root.get("Error", "Unspecified Error").asString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@@ -427,6 +427,7 @@ void PreviewView::OnTick(float dt)
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
addCommentRequest->Finish();
|
||||||
addCommentBox->SetText("");
|
addCommentBox->SetText("");
|
||||||
c->CommentAdded();
|
c->CommentAdded();
|
||||||
}
|
}
|
||||||
@@ -600,6 +601,11 @@ void PreviewView::submitComment()
|
|||||||
if (addCommentBox)
|
if (addCommentBox)
|
||||||
{
|
{
|
||||||
String comment = addCommentBox->GetText();
|
String comment = addCommentBox->GetText();
|
||||||
|
if (comment.length() == 0)
|
||||||
|
{
|
||||||
|
c->CommentAdded();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (comment.length() < 4)
|
if (comment.length() < 4)
|
||||||
{
|
{
|
||||||
new ErrorMessage("Error", "Comment is too short");
|
new ErrorMessage("Error", "Comment is too short");
|
||||||
|
Reference in New Issue
Block a user