Skip to content

Commit

Permalink
1.3.2+31: Fix upsertComment
Browse files Browse the repository at this point in the history
  • Loading branch information
felipebueno committed Jun 8, 2024
1 parent 64b26f5 commit 129f4f5
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 4 deletions.
50 changes: 47 additions & 3 deletions lib/data/api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -553,8 +553,27 @@ final class Api {

final response = await _dio.post(
'https://stacker.news/api/graphql',
data:
"{\"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}\"}",
options: Options(
headers: {
'Content-Type': 'application/json',
},
),
data: jsonEncode(
GqlBody(
operationName: "upsertComment",
variables: {
"parentId": parentId,
"text": text,
},
query: """
mutation upsertComment(\$parentId: ID!, \$text: String!) {
upsertComment(parentId: \$parentId, text: \$text) {
id
}
}
""",
),
),
);

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

if (error != null) {
Utils.showError(error);

throw Exception(error);
}

Expand All @@ -574,3 +592,29 @@ final class Api {
}
// #endregion Items & Comments
}

class GqlBody {
final String? operationName;
final String? query;
final Map<String, dynamic>? variables;

GqlBody({
this.operationName,
this.query,
this.variables,
});

Map<String, dynamic> toJson() => {
'operationName': operationName,
'query': query,
'variables': variables,
};
}

class GqlError {
final String? message;

GqlError({
this.message,
});
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ description: A new Flutter project.
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.3.1+30
version: 1.3.2+31

environment:
sdk: ">=3.4.0 <4.0.0"
Expand Down

0 comments on commit 129f4f5

Please sign in to comment.