mirror of
https://github.com/git-touch/git-touch
synced 2025-01-27 14:19:24 +01:00
fix: handle notification item type: Commit
This commit is contained in:
parent
0a1de91569
commit
84596d3fcf
@ -63,6 +63,7 @@ class _ListScaffoldState extends State<ListScaffold> {
|
||||
try {
|
||||
await widget.onRefresh();
|
||||
} catch (err) {
|
||||
// print(err);
|
||||
error = err.toString();
|
||||
} finally {
|
||||
if (mounted) {
|
||||
|
@ -71,11 +71,8 @@ class _LongListScaffoldState<T, K> extends State<LongListScaffold<T, K>> {
|
||||
try {
|
||||
payload = await widget.onRefresh();
|
||||
} catch (err) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
error = err.toString();
|
||||
});
|
||||
}
|
||||
// print(err);
|
||||
error = err.toString();
|
||||
} finally {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
|
14
lib/screens/not_found.dart
Normal file
14
lib/screens/not_found.dart
Normal file
@ -0,0 +1,14 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../scaffolds/simple.dart';
|
||||
|
||||
class NotFoundScreen extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SimpleScaffold(
|
||||
title: Text('Not Found'),
|
||||
bodyBuilder: () {
|
||||
return Text('Woops, This page is not implemented yet');
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@ import 'package:flutter/cupertino.dart';
|
||||
import '../utils/utils.dart';
|
||||
import '../screens/issue.dart';
|
||||
import '../screens/pull_request.dart';
|
||||
import '../screens/not_found.dart';
|
||||
import '../providers/settings.dart';
|
||||
import 'link.dart';
|
||||
|
||||
@ -25,8 +26,11 @@ class NotificationPayload {
|
||||
owner = input['repository']['owner']['login'];
|
||||
|
||||
String url = input['subject']['url'];
|
||||
String numberStr = url.split('/').lastWhere((_) => true);
|
||||
number = int.parse(numberStr);
|
||||
|
||||
if (type == 'Issue' || type == 'PullRequest') {
|
||||
String numberStr = url.split('/').lastWhere((_) => true);
|
||||
number = int.parse(numberStr);
|
||||
}
|
||||
|
||||
title = input['subject']['title'];
|
||||
updateAt = TimeAgo.formatFromString(input['updated_at']);
|
||||
@ -68,9 +72,11 @@ class _NotificationItemState extends State<NotificationItem> {
|
||||
);
|
||||
case 'Release':
|
||||
// return
|
||||
case 'Commit':
|
||||
// return
|
||||
default:
|
||||
// throw new Exception('Unhandled notification type: $type');
|
||||
return Text('test');
|
||||
print('Unhandled notification type: ${payload.type}');
|
||||
return NotFoundScreen();
|
||||
}
|
||||
}
|
||||
|
||||
@ -105,8 +111,11 @@ class _NotificationItemState extends State<NotificationItem> {
|
||||
// color: Color.fromRGBO(0x6f, 0x42, 0xc1, 1),
|
||||
case 'Release':
|
||||
return _buildIcon(Octicons.tag);
|
||||
case 'Commit':
|
||||
return _buildIcon(Octicons.git_commit);
|
||||
default:
|
||||
return _buildIcon(Octicons.person);
|
||||
print('Unhandled notification type: ${payload.type}');
|
||||
return _buildIcon(Octicons.octoface);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user