[PR #1952] [MERGED] [SG-386] iOS Update user state when coming from background #3248

Closed
opened 2025-11-26 23:30:15 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/bitwarden/android/pull/1952
Author: @fedemkr
Created: 6/15/2022
Status: Merged
Merged: 6/15/2022
Merged by: @fedemkr

Base: masterHead: bug/SG-386-active-user-refresh-fix


📝 Commits (4)

  • 072935d SG-386 Updated active user when coming from background to the iOS app and the extension had switched users
  • 5e0efd2 Merge branch 'master' into bug/SG-386-active-user-refresh-fix
  • 747c842 Added iOSExtensionActiveUserIdKey to preference keys
  • 3a26937 Reorder iOS preference keys

📊 Changes

11 files changed (+79 additions, -27 deletions)

View changed files

📝 src/Android/MainApplication.cs (+1 -1)
📝 src/App/App.xaml.cs (+1 -0)
📝 src/App/Controls/AccountSwitchingOverlay/AccountSwitchingOverlayViewModel.cs (+15 -10)
📝 src/App/Services/MobileStorageService.cs (+2 -1)
📝 src/App/Utilities/AccountManagement/AccountsManager.cs (+2 -12)
📝 src/Core/Abstractions/IStateService.cs (+2 -0)
📝 src/Core/Constants.cs (+1 -0)
📝 src/Core/Services/StateService.cs (+37 -1)
src/Core/Utilities/AccountsManagerMessageCommands.cs (+13 -0)
📝 src/iOS.Core/Utilities/AccountSwitchingOverlayHelper.cs (+4 -1)
📝 src/iOS.Core/Utilities/iOSCoreHelpers.cs (+1 -1)

📄 Description

Type of change

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

Objective

On iOS, when coming from background to the app we should check if any extension has switched users, and if so, change the user as well on the app.

Code changes

  • MainApplication.cs: Updated StateService to include the messenger
  • App.xaml.cs: Calls check for extension user id change when resuming the app (background to foreground)
  • AccountSwitchingOverlayViewModel.cs: Added FromIOSExtension and if that's the case save the user id if the account has been switched. Also, refactored a bit the if to have less branches and applied the constants.
  • AccountsManager.cs: Changed invoking on main thread to be awaited, thus the exception can bubble up
  • Constants.cs: Added iOSExtensionActiveUserIdKey to be used to store the active user id on the extension if it has changed so that it can be updated on the main app when coming to foreground again.
  • StateService.cs: Added CheckExtensionActiveUserAndSwitchIfNeededAsync() to do the actual verification and switch the account if necessary and the method to get/save the extension active user id.
  • AccountsManagerMessageCommands.cs: Moved to Core project to be used in StateService
  • AccountSwitchingOverlayHelper.cs: Applied the FromIOSExtension to true to enable saving the extension user id
  • iOSCoreHelpers.cs: Updated StateService to include the messenger
  • MobileStorageService.cs: Added iOSExtensionActiveUserIdKey to the preference storage keys

Before you submit

  • I have checked for formatting errors (dotnet tool run dotnet-format --check) (required)
  • I have added unit tests where it makes sense to do so (encouraged but not required)
  • This change requires a documentation update (notify the documentation team)
  • This change has particular deployment requirements (notify the DevOps team)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/bitwarden/android/pull/1952 **Author:** [@fedemkr](https://github.com/fedemkr) **Created:** 6/15/2022 **Status:** ✅ Merged **Merged:** 6/15/2022 **Merged by:** [@fedemkr](https://github.com/fedemkr) **Base:** `master` ← **Head:** `bug/SG-386-active-user-refresh-fix` --- ### 📝 Commits (4) - [`072935d`](https://github.com/bitwarden/android/commit/072935d96255e2ff2adfc01b5c4211373bf9f536) SG-386 Updated active user when coming from background to the iOS app and the extension had switched users - [`5e0efd2`](https://github.com/bitwarden/android/commit/5e0efd26162714604ee465a53a6f83cdaea2e61e) Merge branch 'master' into bug/SG-386-active-user-refresh-fix - [`747c842`](https://github.com/bitwarden/android/commit/747c8420ca83e7ba77e9a032af0ddacbcd1c86f9) Added iOSExtensionActiveUserIdKey to preference keys - [`3a26937`](https://github.com/bitwarden/android/commit/3a26937f6f6b79ebb7109734bbd10099b3bc8805) Reorder iOS preference keys ### 📊 Changes **11 files changed** (+79 additions, -27 deletions) <details> <summary>View changed files</summary> 📝 `src/Android/MainApplication.cs` (+1 -1) 📝 `src/App/App.xaml.cs` (+1 -0) 📝 `src/App/Controls/AccountSwitchingOverlay/AccountSwitchingOverlayViewModel.cs` (+15 -10) 📝 `src/App/Services/MobileStorageService.cs` (+2 -1) 📝 `src/App/Utilities/AccountManagement/AccountsManager.cs` (+2 -12) 📝 `src/Core/Abstractions/IStateService.cs` (+2 -0) 📝 `src/Core/Constants.cs` (+1 -0) 📝 `src/Core/Services/StateService.cs` (+37 -1) ➕ `src/Core/Utilities/AccountsManagerMessageCommands.cs` (+13 -0) 📝 `src/iOS.Core/Utilities/AccountSwitchingOverlayHelper.cs` (+4 -1) 📝 `src/iOS.Core/Utilities/iOSCoreHelpers.cs` (+1 -1) </details> ### 📄 Description ## Type of change - [X] Bug fix - [X] New feature development - [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc) - [ ] Build/deploy pipeline (DevOps) - [ ] Other ## Objective <!--Describe what the purpose of this PR is. For example: what bug you're fixing or what new feature you're adding--> On iOS, when coming from background to the app we should check if any extension has switched users, and if so, change the user as well on the app. ## Code changes <!--Explain the changes you've made to each file or major component. This should help the reviewer understand your changes--> <!--Also refer to any related changes or PRs in other repositories--> * **MainApplication.cs:** Updated `StateService` to include the messenger * **App.xaml.cs:** Calls check for extension user id change when resuming the app (background to foreground) * **AccountSwitchingOverlayViewModel.cs:** Added `FromIOSExtension` and if that's the case save the user id if the account has been switched. Also, refactored a bit the if to have less branches and applied the constants. * **AccountsManager.cs:** Changed invoking on main thread to be awaited, thus the exception can bubble up * **Constants.cs:** Added `iOSExtensionActiveUserIdKey` to be used to store the active user id on the extension if it has changed so that it can be updated on the main app when coming to foreground again. * **StateService.cs:** Added `CheckExtensionActiveUserAndSwitchIfNeededAsync()` to do the actual verification and switch the account if necessary and the method to get/save the extension active user id. * **AccountsManagerMessageCommands.cs:** Moved to `Core` project to be used in `StateService` * **AccountSwitchingOverlayHelper.cs:** Applied the `FromIOSExtension` to `true` to enable saving the extension user id * **iOSCoreHelpers.cs:** Updated `StateService` to include the messenger * **MobileStorageService.cs:** Added `iOSExtensionActiveUserIdKey` to the preference storage keys ## Before you submit - [X] I have checked for formatting errors (`dotnet tool run dotnet-format --check`) (required) - [ ] I have added **unit tests** where it makes sense to do so (encouraged but not required) - [ ] This change requires a **documentation update** (notify the documentation team) - [ ] This change has particular **deployment requirements** (notify the DevOps team) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-26 23:30:15 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/android#3248