Skip to content

Commit 129f4f5

Browse files
committed
1.3.2+31: Fix upsertComment
1 parent 64b26f5 commit 129f4f5

File tree

2 files changed

+48
-4
lines changed

2 files changed

+48
-4
lines changed

lib/data/api.dart

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -553,8 +553,27 @@ final class Api {
553553

554554
final response = await _dio.post(
555555
'https://stacker.news/api/graphql',
556-
data:
557-
"{\"operationName\":\"upsertComment\",\"variables\":{\"parentId\":\"$parentId\",\"text\":\"$text\"},\"query\":\"fragment CommentFields on Item {\\n id\\n parentId\\n createdAt\\n deletedAt\\n text\\n user {\\n id\\n name\\n optional {\\n streak\\n __typename\\n }\\n meMute\\n __typename\\n }\\n sats\\n upvotes\\n wvotes\\n boost\\n meSats\\n meDontLike\\n meBookmark\\n meSubscription\\n outlawed\\n freebie\\n path\\n commentSats\\n mine\\n otsHash\\n ncomments\\n imgproxyUrls\\n __typename\\n}\\n\\nfragment CommentsRecursive on Item {\\n ...CommentFields\\n comments {\\n ...CommentFields\\n comments {\\n ...CommentFields\\n comments {\\n ...CommentFields\\n comments {\\n ...CommentFields\\n comments {\\n ...CommentFields\\n comments {\\n ...CommentFields\\n comments {\\n ...CommentFields\\n __typename\\n }\\n __typename\\n }\\n __typename\\n }\\n __typename\\n }\\n __typename\\n }\\n __typename\\n }\\n __typename\\n }\\n __typename\\n}\\n\\nmutation upsertComment(\$text: String!, \$parentId: ID!, \$hash: String, \$hmac: String) {\\n upsertComment(text: \$text, parentId: \$parentId, hash: \$hash, hmac: \$hmac) {\\n ...CommentFields\\n comments {\\n ...CommentsRecursive\\n __typename\\n }\\n __typename\\n }\\n}\"}",
556+
options: Options(
557+
headers: {
558+
'Content-Type': 'application/json',
559+
},
560+
),
561+
data: jsonEncode(
562+
GqlBody(
563+
operationName: "upsertComment",
564+
variables: {
565+
"parentId": parentId,
566+
"text": text,
567+
},
568+
query: """
569+
mutation upsertComment(\$parentId: ID!, \$text: String!) {
570+
upsertComment(parentId: \$parentId, text: \$text) {
571+
id
572+
}
573+
}
574+
""",
575+
),
576+
),
558577
);
559578

560579
if (response.statusCode == 200) {
@@ -563,7 +582,6 @@ final class Api {
563582

564583
if (error != null) {
565584
Utils.showError(error);
566-
567585
throw Exception(error);
568586
}
569587

@@ -574,3 +592,29 @@ final class Api {
574592
}
575593
// #endregion Items & Comments
576594
}
595+
596+
class GqlBody {
597+
final String? operationName;
598+
final String? query;
599+
final Map<String, dynamic>? variables;
600+
601+
GqlBody({
602+
this.operationName,
603+
this.query,
604+
this.variables,
605+
});
606+
607+
Map<String, dynamic> toJson() => {
608+
'operationName': operationName,
609+
'query': query,
610+
'variables': variables,
611+
};
612+
}
613+
614+
class GqlError {
615+
final String? message;
616+
617+
GqlError({
618+
this.message,
619+
});
620+
}

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ description: A new Flutter project.
1111
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
1212
# Read more about iOS versioning at
1313
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
14-
version: 1.3.1+30
14+
version: 1.3.2+31
1515

1616
environment:
1717
sdk: ">=3.4.0 <4.0.0"

0 commit comments

Comments
 (0)