From c53a85cd505465b72e92bbe6a19eed465daccf2f Mon Sep 17 00:00:00 2001 From: mp-bw <59324545+mp-bw@users.noreply.github.com> Date: Wed, 15 Jun 2022 10:43:54 -0400 Subject: [PATCH] [SG-390] Fix for missing org items with single org & personal ownership enabled (#1953) * fix for missing org items with single org & personal ownership enabled * fix for ui issue with vault filter state change on pull to refresh --- src/App/Pages/VaultFilterViewModel.cs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/App/Pages/VaultFilterViewModel.cs b/src/App/Pages/VaultFilterViewModel.cs index 0a801a97c..24ea7f042 100644 --- a/src/App/Pages/VaultFilterViewModel.cs +++ b/src/App/Pages/VaultFilterViewModel.cs @@ -19,7 +19,7 @@ namespace Bit.App.Pages protected abstract ILogger logger { get; } protected bool _showVaultFilter; - protected bool _hideMyVaultFilterOption; + protected bool _personalOwnershipPolicyApplies; protected string _vaultFilterSelection; protected List _organizations; @@ -64,15 +64,21 @@ namespace Bit.App.Pages protected async Task InitVaultFilterAsync() { _organizations = await organizationService.GetAllAsync(); - ShowVaultFilter = await policyService.ShouldShowVaultFilterAsync(); - if (ShowVaultFilter) + if (_organizations?.Any() ?? false) { - _hideMyVaultFilterOption = await policyService.PolicyAppliesToUser(PolicyType.PersonalOwnership); - if (_vaultFilterSelection == null) + _personalOwnershipPolicyApplies = await policyService.PolicyAppliesToUser(PolicyType.PersonalOwnership); + var singleOrgPolicyApplies = await policyService.PolicyAppliesToUser(PolicyType.OnlyOrg); + if (_personalOwnershipPolicyApplies && singleOrgPolicyApplies) { - _vaultFilterSelection = AppResources.AllVaults; + VaultFilterDescription = _organizations.First().Name; + } + else if (_vaultFilterSelection == null) + { + VaultFilterDescription = AppResources.AllVaults; } } + await Task.Delay(100); + ShowVaultFilter = await policyService.ShouldShowVaultFilterAsync(); } protected async Task> GetAllCiphersAsync() @@ -93,7 +99,7 @@ namespace Bit.App.Pages protected async Task VaultFilterOptionsAsync() { var options = new List { AppResources.AllVaults }; - if (!_hideMyVaultFilterOption) + if (!_personalOwnershipPolicyApplies) { options.Add(AppResources.MyVault); }