fix: api change user to accountID (#85)

closes #79
This commit is contained in:
Shreyas Thirumalai 2020-05-11 18:27:18 +05:30 committed by GitHub
parent 5ad1ab63f2
commit 8a1180dae8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 11 additions and 2 deletions

View File

@ -12,6 +12,7 @@ class Account {
String avatarUrl;
int gitlabId; // For GitLab
String appPassword; // For Bitbucket
String accountId; // For Bitbucket
// equals(Account a) {
// final uri = Uri.parse(domain);
@ -33,6 +34,7 @@ class Account {
@required this.avatarUrl,
this.gitlabId,
this.appPassword,
this.accountId,
});
factory Account.fromJson(Map<String, dynamic> json) =>

View File

@ -15,6 +15,7 @@ Account _$AccountFromJson(Map<String, dynamic> json) {
avatarUrl: json['avatarUrl'] as String,
gitlabId: json['gitlabId'] as int,
appPassword: json['appPassword'] as String,
accountId: json['accountId'] as String,
);
}
@ -34,5 +35,6 @@ Map<String, dynamic> _$AccountToJson(Account instance) {
writeNotNull('avatarUrl', instance.avatarUrl);
writeNotNull('gitlabId', instance.gitlabId);
writeNotNull('appPassword', instance.appPassword);
writeNotNull('accountId', instance.accountId);
return val;
}

View File

@ -267,6 +267,7 @@ class AuthModel with ChangeNotifier {
login: username,
avatarUrl: user.avatarUrl,
appPassword: appPassword,
accountId: user.accountId,
));
} finally {
loading = false;

View File

@ -30,6 +30,7 @@ class BbUser extends BbRepoOwner {
String username;
bool isStaff;
DateTime createdOn;
String accountId;
BbUser();
factory BbUser.fromJson(Map<String, dynamic> json) => _$BbUserFromJson(json);
}

View File

@ -50,7 +50,8 @@ BbUser _$BbUserFromJson(Map<String, dynamic> json) {
..isStaff = json['is_staff'] as bool
..createdOn = json['created_on'] == null
? null
: DateTime.parse(json['created_on'] as String);
: DateTime.parse(json['created_on'] as String)
..accountId = json['account_id'] as String;
}
Map<String, dynamic> _$BbUserToJson(BbUser instance) => <String, dynamic>{
@ -61,6 +62,7 @@ Map<String, dynamic> _$BbUserToJson(BbUser instance) => <String, dynamic>{
'username': instance.username,
'is_staff': instance.isStaff,
'created_on': instance.createdOn?.toIso8601String(),
'account_id': instance.accountId,
};
BbRepo _$BbRepoFromJson(Map<String, dynamic> json) {

View File

@ -19,12 +19,13 @@ class BbUserScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
final auth = Provider.of<AuthModel>(context);
final _accountId = auth.activeAccount.accountId;
final _login = login ?? auth.activeAccount.login;
return RefreshStatefulScaffold<Tuple2<BbUser, Iterable<BbRepo>>>(
title: Text(isViewer ? 'Me' : isTeam ? 'Team' : 'User'),
fetchData: () async {
final res = await Future.wait([
auth.fetchBbJson('/${isTeam ? 'teams' : 'users'}/$_login'),
auth.fetchBbJson('/${isTeam ? 'teams' : 'users'}/$_accountId'),
auth.fetchBbWithPage('/repositories/$_login'),
]);
return Tuple2(