diff --git a/lib/screens/gh_issue_form.dart b/lib/screens/gh_issue_form.dart index a49e00b..f468226 100644 --- a/lib/screens/gh_issue_form.dart +++ b/lib/screens/gh_issue_form.dart @@ -25,6 +25,8 @@ class _GhIssueFormScreenState extends State { @override Widget build(BuildContext context) { final theme = Provider.of(context); + final auth = Provider.of(context); + return CommonScaffold( title: Text('Submit an issue'), body: Column( @@ -57,22 +59,10 @@ class _GhIssueFormScreenState extends State { CupertinoButton.filled( child: Text('Submit'), onPressed: () async { - final auth = Provider.of(context); - final theme = Provider.of(context); - final slug = RepositorySlug(widget.owner, widget.name); - // TODO: https://github.com/SpinlockLabs/github.dart/issues/211 - // final res = await auth.ghClient.issues - // .create(slug, IssueRequest(title: _title, body: _body)); - - final response = await auth.ghClient.request( - 'POST', - '/repos/${slug.fullName}/issues', - body: jsonEncode({'title': _title, 'body': _body}), - ); - final res = Issue.fromJson( - jsonDecode(response.body) as Map); + final res = await auth.ghClient.issues + .create(slug, IssueRequest(title: _title, body: _body)); await theme.push( context, '/github/${widget.owner}/${widget.name}/issues/${res.number}', diff --git a/lib/screens/gh_repo.dart b/lib/screens/gh_repo.dart index dea3c78..7b51d0b 100644 --- a/lib/screens/gh_repo.dart +++ b/lib/screens/gh_repo.dart @@ -138,35 +138,15 @@ class GhRepoScreen extends StatelessWidget { switch (v) { case GhRepoSubscriptionState.SUBSCRIBED: case GhRepoSubscriptionState.IGNORED: - // TODO: https://github.com/SpinlockLabs/github.dart/pull/215 - // final res = await auth.ghClient.activity - // .setRepositorySubscription( - // RepositorySlug( - // repo.owner.login, - // repo.name, - // ), - // subscribed: v == - // GhRepoSubscriptionState.SUBSCRIBED, - // ignored: - // v == GhRepoSubscriptionState.IGNORED, - // ); - final slug = RepositorySlug( - repo.owner.login, repo.name); - final response = - await auth.ghClient.request( - 'PUT', - '/repos/${slug.fullName}/subscription', - statusCode: StatusCodes.OK, - body: json.encode({ - 'subscribed': v == - GhRepoSubscriptionState.SUBSCRIBED, - 'ignored': - v == GhRepoSubscriptionState.IGNORED - }), + final res = await auth.ghClient.activity + .setRepositorySubscription( + RepositorySlug( + repo.owner.login, repo.name), + subscribed: v == + GhRepoSubscriptionState.SUBSCRIBED, + ignored: + v == GhRepoSubscriptionState.IGNORED, ); - final res = RepositorySubscription.fromJson( - jsonDecode(response.body) - as Map); setState(() { if (res.subscribed) { repo.viewerSubscription = diff --git a/lib/screens/gh_user.dart b/lib/screens/gh_user.dart index 27e21d3..b1667e3 100644 --- a/lib/screens/gh_user.dart +++ b/lib/screens/gh_user.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:git_touch/graphql/gh.dart'; -import 'package:git_touch/models/github.dart'; import 'package:git_touch/models/theme.dart'; import 'package:git_touch/scaffolds/refresh_stateful.dart'; import 'package:git_touch/utils/utils.dart'; @@ -80,11 +79,7 @@ class GhUserScreen extends StatelessWidget { if (p.viewerIsFollowing) { await auth.ghClient.users.unfollowUser(p.login); } else { - // TODO: https://github.com/SpinlockLabs/github.dart/pull/216 - // await auth.ghClient.users.followUser(p.login); - await auth.ghClient.request( - 'PUT', '/user/following/${p.login}', - statusCode: 204); + await auth.ghClient.users.followUser(p.login); } setState(() { p.viewerIsFollowing = !p.viewerIsFollowing;