fix(gt): me screen login

This commit is contained in:
Rongjian Zhang 2020-10-05 20:39:48 +08:00
parent 2557ad2d07
commit 890c44c4c5
2 changed files with 5 additions and 6 deletions

View File

@ -83,7 +83,7 @@ class _HomeState extends State<Home> {
case 0:
return GtOrgsScreen();
case 1:
return GtUserScreen(null);
return GtUserScreen(auth.activeAccount.login, isViewer: true);
}
break;
}

View File

@ -20,21 +20,20 @@ class GtUserScreenPayload {
class GtUserScreen extends StatelessWidget {
final String login;
GtUserScreen(this.login);
bool get isViewer => login == null;
final bool isViewer;
GtUserScreen(this.login, {this.isViewer = false});
@override
Widget build(BuildContext context) {
return RefreshStatefulScaffold<GtUserScreenPayload>(
title: Text(login ?? 'Me'),
title: Text(isViewer ? 'Me' : login),
fetchData: () async {
final auth = context.read<AuthModel>();
final res = await Future.wait([
auth.fetchGitea(isViewer ? '/user' : '/users/$login'),
auth.fetchGitea(
isViewer ? '/user/repos?limit=6' : '/users/$login/repos?limit=6'),
auth.fetchGitea(
'/users/${login ?? auth.activeAccount.login}/heatmap'),
auth.fetchGitea('/users/$login/heatmap'),
auth.fetchGitea('/orgs/$login'),
auth.fetchGitea('/orgs/$login/repos'),
]);