diff --git a/lib/models/account.dart b/lib/models/account.dart index 1c7b9f8..23afeec 100644 --- a/lib/models/account.dart +++ b/lib/models/account.dart @@ -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 json) => diff --git a/lib/models/account.g.dart b/lib/models/account.g.dart index 5afdd11..37e5020 100644 --- a/lib/models/account.g.dart +++ b/lib/models/account.g.dart @@ -15,6 +15,7 @@ Account _$AccountFromJson(Map 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 _$AccountToJson(Account instance) { writeNotNull('avatarUrl', instance.avatarUrl); writeNotNull('gitlabId', instance.gitlabId); writeNotNull('appPassword', instance.appPassword); + writeNotNull('accountId', instance.accountId); return val; } diff --git a/lib/models/auth.dart b/lib/models/auth.dart index 2bd24ca..9871f7e 100644 --- a/lib/models/auth.dart +++ b/lib/models/auth.dart @@ -267,6 +267,7 @@ class AuthModel with ChangeNotifier { login: username, avatarUrl: user.avatarUrl, appPassword: appPassword, + accountId: user.accountId, )); } finally { loading = false; diff --git a/lib/models/bitbucket.dart b/lib/models/bitbucket.dart index 6624009..1f6072b 100644 --- a/lib/models/bitbucket.dart +++ b/lib/models/bitbucket.dart @@ -30,6 +30,7 @@ class BbUser extends BbRepoOwner { String username; bool isStaff; DateTime createdOn; + String accountId; BbUser(); factory BbUser.fromJson(Map json) => _$BbUserFromJson(json); } diff --git a/lib/models/bitbucket.g.dart b/lib/models/bitbucket.g.dart index 13fc0f2..286c24b 100644 --- a/lib/models/bitbucket.g.dart +++ b/lib/models/bitbucket.g.dart @@ -50,7 +50,8 @@ BbUser _$BbUserFromJson(Map 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 _$BbUserToJson(BbUser instance) => { @@ -61,6 +62,7 @@ Map _$BbUserToJson(BbUser instance) => { 'username': instance.username, 'is_staff': instance.isStaff, 'created_on': instance.createdOn?.toIso8601String(), + 'account_id': instance.accountId, }; BbRepo _$BbRepoFromJson(Map json) { diff --git a/lib/screens/bb_user.dart b/lib/screens/bb_user.dart index bf2529c..9ffa8d4 100644 --- a/lib/screens/bb_user.dart +++ b/lib/screens/bb_user.dart @@ -19,12 +19,13 @@ class BbUserScreen extends StatelessWidget { @override Widget build(BuildContext context) { final auth = Provider.of(context); + final _accountId = auth.activeAccount.accountId; final _login = login ?? auth.activeAccount.login; return RefreshStatefulScaffold>>( 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(