Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PM-7407] Implemented check for organizations with unassigned items #3150

Merged
merged 2 commits into from
Apr 12, 2024

Conversation

fedemkr
Copy link
Member

@fedemkr fedemkr commented Apr 11, 2024

Type of change

  • Bug fix
  • New feature development
  • Tech debt (refactoring, code cleanup, dependency upgrades, etc)
  • Build/deploy pipeline (DevOps)
  • Other

Objective

Add check for organization with unassigned items to display a message to the user if it's needed.

Code changes

  • Constants: Added new feature flag for this check
  • ApiService: Added new endpoint call to check whether the organization has any unassigned items
  • CipherService: Added method to verify if an organization has any unassigned items
  • AppOptions: Added flag to see if the user has just logged in / unlocked their vault when displaying the GroupingsPage
    • Other files related with AppOptions: Updated the new flag of AppOptions and passed along the options object to get to the GroupingsPage
  • StateService: Added new Get/Set method for the flag of if one should or not perform this check
  • GroupingsPageViewModel: Added logic to check the organization unassigned items based on the feature flag and the "should check" local flag (depending on what the user chose on an already shown dialog). Also, it waits if a sync is in progress to have the latest data locally as I'm checking whether the user has any organizations so not to call the endpoint on the cases where the user doesn't belong to an org.

Screenshots

Unassigned items notice iOS

Unassigned items notice iOS

Unassigned items notice iOS

Unassigned items notice Android

Unassigned items notice Android

Unassigned items notice Android

Before you submit

  • Please check for formatting errors (dotnet format --verify-no-changes) (required)
  • Please add unit tests where it makes sense to do so (encouraged but not required)
  • If this change requires a documentation update - notify the documentation team
  • If this change has particular deployment requirements - notify the DevOps team

@fedemkr fedemkr requested a review from a team as a code owner April 11, 2024 23:01
@@ -186,6 +186,8 @@ public interface IStateService
Task<BwRegion?> GetActiveUserRegionAsync();
Task<BwRegion?> GetPreAuthRegionAsync();
Task SetPreAuthRegionAsync(BwRegion value);
Task<bool> GetShouldCheckOrganizationUnassignedItemsAsync(string userId = null);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 Naming wise, following a similar pattern to the other prompts (e.g. Get/Set UnassignedItemsPromptShownAsync) would make it easier to find this in the future.

Copy link
Member Author

@fedemkr fedemkr Apr 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that this getter doesn't return if the prompt has been shown or not, it returns whether the check (and potentially the prompt) should be done or not, i.e. if the user chose "Remind me later" or not.
Also there are also two other that have Should:

  • GetShouldTrustDeviceAsync
  • GetShouldConnectToWatchAsync

Even though I agree having everything with the same name structure is better, but on the other hand I like having specific naming so one can exactly know what the method/property does without having to look much in other places.
What do you think?

@@ -136,6 +137,7 @@ public static class Constants
public static string ShouldConnectToWatchKey(string userId) => $"shouldConnectToWatch_{userId}";
public static string ScreenCaptureAllowedKey(string userId) => $"screenCaptureAllowed_{userId}";
public static string PendingAdminAuthRequest(string userId) => $"pendingAdminAuthRequest_{userId}";
public static string ShouldCheckOrganizationUnassignedItemsKey(string userId) => $"shouldCheckOrganizationUnassignedItems_{userId}";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⛏️ (not really relevant but worth mentioning) other similar constants don't have verbiage like "ShouldCheck".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO without the "should check" one doesn't know what the flag is for, only that it has to do with organization unassigned items. However, if having the verbiage alike others is more important I can change it.

@@ -829,6 +829,24 @@ public async Task RestoreWithServerAsync(string id)
await ClearCacheAsync();
}

public async Task<bool> VerifyOrganizationHasUnassignedItemsAsync()
{
var organizations = await _stateService.GetOrganizationsAsync();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 I'm not sure if it's possible for this to return 0 orgs and the next call returning true, I just noticed other clients aren't checking this.

Copy link
Member Author

@fedemkr fedemkr Apr 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is exactly why I had to wait for synchronization to complete, otherwise we'd have 0 orgs right after logging in given the sync wouldn't have finished.
I could remove this alongside the sync wait but it will fire a request to the server for users that don't have organizations which IMO is a waste of resources and given that we're waiting for sync to finish we should have the latest organizations state when checking it.

@@ -233,6 +233,7 @@ private async Task UnlockedAsync()
}
var previousPage = await AppHelpers.ClearPreviousPage();

_appOptions.HasJustLoggedInOrUnlocked = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💭 Instead of having this variable scattered around and risk missing a path to the vault, can't we just check once on TabsPage.OnCreate with a control variable HasRunCheckOrganizationUnassignedItems?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that TabsPage.OnCreate can be called when the vault has timeout never, then it's not technically after login/unlock as it will be called when opening the app and given timeout never the vault would be already unlocked.

Copy link
Member

@vvolkgang vvolkgang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding the self-host message!

@fedemkr fedemkr merged commit e7a7eed into main Apr 12, 2024
11 of 12 checks passed
@fedemkr fedemkr deleted the mobiletf/pm-7407/popup-organization-unassigned-items branch April 12, 2024 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants