mirror of
https://github.com/git-touch/git-touch
synced 2025-01-31 16:14:49 +01:00
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;
|
||||
}
|
||||
|
||||
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;
|
||||
void redirectToGithubOauth() {
|
||||
_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/widgets/action_entry.dart';
|
||||
import 'package:git_touch/widgets/app_bar_title.dart';
|
||||
import 'package:github/github.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:git_touch/models/notification.dart';
|
||||
import 'package:git_touch/models/auth.dart';
|
||||
@ -102,7 +103,8 @@ ${item.key}: pullRequest(number: ${item.subject.number}) {
|
||||
Widget _buildGroupItem(
|
||||
BuildContext context,
|
||||
MapEntry<String, NotificationGroup> entry,
|
||||
Map<String, NotificationGroup> groupMap) {
|
||||
Map<String, NotificationGroup> groupMap,
|
||||
) {
|
||||
final theme = Provider.of<ThemeModel>(context);
|
||||
final group = entry.value;
|
||||
return ListGroup(
|
||||
@ -119,8 +121,9 @@ ${item.key}: pullRequest(number: ${item.subject.number}) {
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
await Provider.of<AuthModel>(context)
|
||||
.putWithCredentials('/repos/${group.fullName}/notifications');
|
||||
final auth = Provider.of<AuthModel>(context);
|
||||
await auth.ghClient.activity.markRepositoryNotificationsRead(
|
||||
RepositorySlug.full(group.fullName));
|
||||
// await _onSwitchTab(); // TODO:
|
||||
},
|
||||
child: Icon(
|
||||
@ -172,7 +175,9 @@ ${item.key}: pullRequest(number: ${item.subject.number}) {
|
||||
.showConfirm(context, Text('Mark all as read?'));
|
||||
if (value) {
|
||||
await Provider.of<AuthModel>(context)
|
||||
.putWithCredentials('/notifications');
|
||||
.ghClient
|
||||
.activity
|
||||
.markNotificationsRead();
|
||||
refresh();
|
||||
}
|
||||
},
|
||||
|
@ -84,7 +84,9 @@ class _NotificationItemState extends State<NotificationItem> {
|
||||
});
|
||||
try {
|
||||
await Provider.of<AuthModel>(context)
|
||||
.patchWithCredentials('/notifications/threads/${payload.id}');
|
||||
.ghClient
|
||||
.activity
|
||||
.markThreadRead(payload.id);
|
||||
widget.markAsRead();
|
||||
} finally {
|
||||
if (mounted) {
|
||||
|
@ -40,7 +40,11 @@ dependencies:
|
||||
gql_link: ^0.2.0
|
||||
fluro: ^1.5.1
|
||||
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.
|
||||
# Use with the CupertinoIcons class for iOS style icons.
|
||||
cupertino_icons: ^0.1.2
|
||||
|
Loading…
x
Reference in New Issue
Block a user