refactor(gh): use github lib
This commit is contained in:
parent
0ee36143f8
commit
e772059f23
|
@ -414,26 +414,6 @@ class AuthModel with ChangeNotifier {
|
||||||
return res.body;
|
return res.body;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> patchWithCredentials(String url) async {
|
|
||||||
await http
|
|
||||||
.patch(_apiPrefix + url, headers: _headers)
|
|
||||||
.timeout(_timeoutDuration);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<http.Response> putWithCredentials(
|
|
||||||
String url, {
|
|
||||||
String contentType = 'application/json',
|
|
||||||
Map<String, dynamic> body = const {},
|
|
||||||
}) async {
|
|
||||||
return http
|
|
||||||
.put(
|
|
||||||
_apiPrefix + url,
|
|
||||||
headers: {..._headers, HttpHeaders.contentTypeHeader: contentType},
|
|
||||||
body: json.encode(body),
|
|
||||||
)
|
|
||||||
.timeout(_timeoutDuration);
|
|
||||||
}
|
|
||||||
|
|
||||||
String _oauthState;
|
String _oauthState;
|
||||||
void redirectToGithubOauth() {
|
void redirectToGithubOauth() {
|
||||||
_oauthState = nanoid();
|
_oauthState = nanoid();
|
||||||
|
|
|
@ -4,6 +4,7 @@ import 'package:git_touch/models/theme.dart';
|
||||||
import 'package:git_touch/scaffolds/tab_stateful.dart';
|
import 'package:git_touch/scaffolds/tab_stateful.dart';
|
||||||
import 'package:git_touch/widgets/action_entry.dart';
|
import 'package:git_touch/widgets/action_entry.dart';
|
||||||
import 'package:git_touch/widgets/app_bar_title.dart';
|
import 'package:git_touch/widgets/app_bar_title.dart';
|
||||||
|
import 'package:github/github.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:git_touch/models/notification.dart';
|
import 'package:git_touch/models/notification.dart';
|
||||||
import 'package:git_touch/models/auth.dart';
|
import 'package:git_touch/models/auth.dart';
|
||||||
|
@ -100,9 +101,10 @@ ${item.key}: pullRequest(number: ${item.subject.number}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildGroupItem(
|
Widget _buildGroupItem(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
MapEntry<String, NotificationGroup> entry,
|
MapEntry<String, NotificationGroup> entry,
|
||||||
Map<String, NotificationGroup> groupMap) {
|
Map<String, NotificationGroup> groupMap,
|
||||||
|
) {
|
||||||
final theme = Provider.of<ThemeModel>(context);
|
final theme = Provider.of<ThemeModel>(context);
|
||||||
final group = entry.value;
|
final group = entry.value;
|
||||||
return ListGroup(
|
return ListGroup(
|
||||||
|
@ -119,8 +121,9 @@ ${item.key}: pullRequest(number: ${item.subject.number}) {
|
||||||
),
|
),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
await Provider.of<AuthModel>(context)
|
final auth = Provider.of<AuthModel>(context);
|
||||||
.putWithCredentials('/repos/${group.fullName}/notifications');
|
await auth.ghClient.activity.markRepositoryNotificationsRead(
|
||||||
|
RepositorySlug.full(group.fullName));
|
||||||
// await _onSwitchTab(); // TODO:
|
// await _onSwitchTab(); // TODO:
|
||||||
},
|
},
|
||||||
child: Icon(
|
child: Icon(
|
||||||
|
@ -172,7 +175,9 @@ ${item.key}: pullRequest(number: ${item.subject.number}) {
|
||||||
.showConfirm(context, Text('Mark all as read?'));
|
.showConfirm(context, Text('Mark all as read?'));
|
||||||
if (value) {
|
if (value) {
|
||||||
await Provider.of<AuthModel>(context)
|
await Provider.of<AuthModel>(context)
|
||||||
.putWithCredentials('/notifications');
|
.ghClient
|
||||||
|
.activity
|
||||||
|
.markNotificationsRead();
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -84,7 +84,9 @@ class _NotificationItemState extends State<NotificationItem> {
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
await Provider.of<AuthModel>(context)
|
await Provider.of<AuthModel>(context)
|
||||||
.patchWithCredentials('/notifications/threads/${payload.id}');
|
.ghClient
|
||||||
|
.activity
|
||||||
|
.markThreadRead(payload.id);
|
||||||
widget.markAsRead();
|
widget.markAsRead();
|
||||||
} finally {
|
} finally {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
|
|
|
@ -40,7 +40,11 @@ dependencies:
|
||||||
gql_link: ^0.2.0
|
gql_link: ^0.2.0
|
||||||
fluro: ^1.5.1
|
fluro: ^1.5.1
|
||||||
package_info: ^0.4.0
|
package_info: ^0.4.0
|
||||||
|
github: #^6.1.0
|
||||||
|
git:
|
||||||
|
url: git://github.com/pd4d10/github.dart.git
|
||||||
|
ref: patch-1
|
||||||
|
#path: ../../github/github.dart
|
||||||
# The following adds the Cupertino Icons font to your application.
|
# The following adds the Cupertino Icons font to your application.
|
||||||
# Use with the CupertinoIcons class for iOS style icons.
|
# Use with the CupertinoIcons class for iOS style icons.
|
||||||
cupertino_icons: ^0.1.2
|
cupertino_icons: ^0.1.2
|
||||||
|
|
Loading…
Reference in New Issue