[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
This commit is contained in:
mp-bw 2022-06-15 10:43:54 -04:00 committed by GitHub
parent 448758a697
commit c53a85cd50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 7 deletions

View File

@ -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<Organization> _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<List<CipherView>> GetAllCiphersAsync()
@ -93,7 +99,7 @@ namespace Bit.App.Pages
protected async Task VaultFilterOptionsAsync()
{
var options = new List<string> { AppResources.AllVaults };
if (!_hideMyVaultFilterOption)
if (!_personalOwnershipPolicyApplies)
{
options.Add(AppResources.MyVault);
}