mirror of
https://github.com/git-touch/git-touch
synced 2025-01-19 02:40:05 +01:00
refactor: resolve todos of github api lib
This commit is contained in:
parent
35b653af65
commit
e9f9d9be03
@ -25,6 +25,8 @@ class _GhIssueFormScreenState extends State<GhIssueFormScreen> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Provider.of<ThemeModel>(context);
|
||||
final auth = Provider.of<AuthModel>(context);
|
||||
|
||||
return CommonScaffold(
|
||||
title: Text('Submit an issue'),
|
||||
body: Column(
|
||||
@ -57,22 +59,10 @@ class _GhIssueFormScreenState extends State<GhIssueFormScreen> {
|
||||
CupertinoButton.filled(
|
||||
child: Text('Submit'),
|
||||
onPressed: () async {
|
||||
final auth = Provider.of<AuthModel>(context);
|
||||
final theme = Provider.of<ThemeModel>(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<String, dynamic>);
|
||||
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}',
|
||||
|
@ -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<String, dynamic>);
|
||||
setState(() {
|
||||
if (res.subscribed) {
|
||||
repo.viewerSubscription =
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user