Skip to content

Commit

Permalink
fix: types
Browse files Browse the repository at this point in the history
  • Loading branch information
pd4d10 committed Jun 14, 2021
1 parent 242dd12 commit 97bd998
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 20 deletions.
2 changes: 1 addition & 1 deletion lib/scaffolds/long_list.dart
Expand Up @@ -11,7 +11,7 @@ import '../widgets/error_reload.dart';
class LongListPayload<T, K> {
T header;
int totalCount;
String cursor;
String? cursor;
List<K> leadingItems;
List<K>? trailingItems;

Expand Down
18 changes: 11 additions & 7 deletions lib/screens/bb_issue.dart
Expand Up @@ -22,17 +22,21 @@ class BbIssueScreen extends StatelessWidget {

@override
Widget build(BuildContext context) {
return RefreshStatefulScaffold<Tuple2<BbIssues, List<BbComment>>>(
return RefreshStatefulScaffold<Tuple2<BbIssues, Iterable<BbComment>>>(
title: Text("Issue: #$number"),
fetch: () async {
final auth = context.read<AuthModel>();
final items = await Future.wait([
auth.fetchBbJson('/repositories/$owner/$name/issues/$number'),
auth.fetchBbWithPage(
'/repositories/$owner/$name/issues/$number/comments')
final res = await Future.wait([
auth
.fetchBbJson('/repositories/$owner/$name/issues/$number')
.then((value) => BbIssues.fromJson(value)),
auth
.fetchBbWithPage(
'/repositories/$owner/$name/issues/$number/comments')
.then(
(value) => [for (var v in value.items) BbComment.fromJson(v)])
]);
return Tuple2(BbIssues.fromJson(items[0]),
[for (var v in items[1].data) BbComment.fromJson(v)]);
return Tuple2(res[0] as BbIssues, res[1] as Iterable<BbComment>);
},
actionBuilder: (data, _) => ActionEntry(
iconData: Octicons.plus,
Expand Down
13 changes: 7 additions & 6 deletions lib/screens/bb_user.dart
Expand Up @@ -29,13 +29,14 @@ class BbUserScreen extends StatelessWidget {
: 'User'),
fetch: () async {
final res = await Future.wait([
auth.fetchBbJson('/${isTeam ? 'teams' : 'users'}/$_accountId'),
auth.fetchBbWithPage('/repositories/$_login'),
auth
.fetchBbJson('/${isTeam ? 'teams' : 'users'}/$_accountId')
.then((value) => BbUser.fromJson(value)),
auth
.fetchBbWithPage('/repositories/$_login')
.then((value) => [for (var v in value.items) BbRepo.fromJson(v)]),
]);
return Tuple2(
BbUser.fromJson(res[0]),
[for (var v in res[1].data) BbRepo.fromJson(v)],
);
return Tuple2(res[0] as BbUser, res[1] as Iterable<BbRepo>);
},
action: isViewer
? ActionEntry(
Expand Down
8 changes: 4 additions & 4 deletions lib/screens/gh_issue.dart
Expand Up @@ -264,7 +264,7 @@ class GhIssueScreen extends StatelessWidget {
return LongListPayload(
header: res,
totalCount: issue.timelineItems.totalCount,
cursor: issue.timelineItems.pageInfo.endCursor!,
cursor: issue.timelineItems.pageInfo.endCursor,
leadingItems: issue.timelineItems.nodes!.toList(),
trailingItems: [],
);
Expand All @@ -274,7 +274,7 @@ class GhIssueScreen extends StatelessWidget {
return LongListPayload(
header: res,
totalCount: pr.timelineItems.totalCount,
cursor: pr.timelineItems.pageInfo.endCursor!,
cursor: pr.timelineItems.pageInfo.endCursor,
leadingItems: pr.timelineItems.nodes!.toList(),
trailingItems: [],
);
Expand All @@ -288,7 +288,7 @@ class GhIssueScreen extends StatelessWidget {
return LongListPayload(
header: res,
totalCount: issue.timelineItems.totalCount,
cursor: issue.timelineItems.pageInfo.endCursor!,
cursor: issue.timelineItems.pageInfo.endCursor,
leadingItems: issue.timelineItems.nodes!.toList(),
);
} else {
Expand All @@ -297,7 +297,7 @@ class GhIssueScreen extends StatelessWidget {
return LongListPayload(
header: res,
totalCount: pr.timelineItems.totalCount,
cursor: pr.timelineItems.pageInfo.endCursor!,
cursor: pr.timelineItems.pageInfo.endCursor,
leadingItems: pr.timelineItems.nodes!.toList(),
);
}
Expand Down
6 changes: 4 additions & 2 deletions lib/screens/go_user.dart
Expand Up @@ -30,8 +30,10 @@ class GoUserScreen extends StatelessWidget {
limit: 6),
]);

return Tuple2(GogsUser.fromJson(res[0]),
[for (var repo in res[1].data) GogsRepository.fromJson(repo)]);
return Tuple2(GogsUser.fromJson(res[0]), [
for (var repo in (res[1] as DataWithPage).data)
GogsRepository.fromJson(repo)
]);
},
action: isViewer
? ActionEntry(
Expand Down

0 comments on commit 97bd998

Please sign in to comment.