Skip to content

Commit

Permalink
fix: Fix eneterpise wallet naming bug #2498
Browse files Browse the repository at this point in the history
  • Loading branch information
bibash28 committed Apr 16, 2024
1 parent 72fc2b4 commit f0dfa22
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 11 deletions.
14 changes: 8 additions & 6 deletions lib/dashboard/drawer/profile/widget/profile_selector_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ class ProfileSelectorWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
final l10n = context.l10n;

final profile = context.read<ProfileCubit>().state.model;

final walletContainsEnterpriseProfile =
profile.walletType == WalletType.enterprise;

return BlocBuilder<ProfileCubit, ProfileState>(
builder: (context, state) {
return Column(
Expand Down Expand Up @@ -53,15 +59,11 @@ class ProfileSelectorWidget extends StatelessWidget {
itemBuilder: (context, index) {
final profileType = ProfileType.values[index];

final profile = context.read<ProfileCubit>().state.model;

final isEnterprise =
profile.walletType == WalletType.enterprise;

if (!isEnterprise &&
if (!walletContainsEnterpriseProfile &&
profileType == ProfileType.enterprise) {
return Container();
}

return Column(
children: [
if (index != 0)
Expand Down
27 changes: 22 additions & 5 deletions lib/dashboard/profile/cubit/profile_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,23 @@ class ProfileCubit extends Cubit<ProfileState> {
}
}

String? enterpriseWalletName;

final enterpriseProfileSettingJsonString =
await secureStorageProvider.get(
SecureStorageKeys.enterpriseProfileSetting,
);

if (enterpriseProfileSettingJsonString != null) {
final ProfileSetting enterpriseProfileSetting = ProfileSetting.fromJson(
json.decode(enterpriseProfileSettingJsonString)
as Map<String, dynamic>,
);

enterpriseWalletName =
enterpriseProfileSetting.generalOptions.profileName;
}

/// profileSetting
late ProfileSetting profileSetting;

Expand Down Expand Up @@ -172,6 +189,7 @@ class ProfileCubit extends Cubit<ProfileState> {
isDeveloperMode: isDeveloperMode,
profileType: profileType,
profileSetting: profileSetting,
enterpriseWalletName: enterpriseWalletName,
);

case ProfileType.defaultOne:
Expand All @@ -193,6 +211,7 @@ class ProfileCubit extends Cubit<ProfileState> {
isDeveloperMode: isDeveloperMode,
clientId: did,
clientSecret: randomString(12),
enterpriseWalletName: enterpriseWalletName,
);

case ProfileType.ebsiV3:
Expand All @@ -214,6 +233,7 @@ class ProfileCubit extends Cubit<ProfileState> {
isDeveloperMode: isDeveloperMode,
clientId: did,
clientSecret: randomString(12),
enterpriseWalletName: enterpriseWalletName,
);

case ProfileType.dutch:
Expand All @@ -235,6 +255,7 @@ class ProfileCubit extends Cubit<ProfileState> {
isDeveloperMode: isDeveloperMode,
clientId: did,
clientSecret: randomString(12),
enterpriseWalletName: enterpriseWalletName,
);

case ProfileType.owfBaselineProfile:
Expand All @@ -256,14 +277,10 @@ class ProfileCubit extends Cubit<ProfileState> {
isDeveloperMode: isDeveloperMode,
clientId: did,
clientSecret: randomString(12),
enterpriseWalletName: enterpriseWalletName,
);

case ProfileType.enterprise:
final enterpriseProfileSettingJsonString =
await secureStorageProvider.get(
SecureStorageKeys.enterpriseProfileSetting,
);

if (enterpriseProfileSettingJsonString != null) {
profileSetting = ProfileSetting.fromJson(
json.decode(enterpriseProfileSettingJsonString)
Expand Down

0 comments on commit f0dfa22

Please sign in to comment.