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

Reset CoreDataManager in the background and optimize logout #14154

Open
wants to merge 4 commits into
base: trunk
Choose a base branch
from

Conversation

itsmeichigo
Copy link
Contributor

@itsmeichigo itsmeichigo commented Oct 18, 2024

Closes: #14153

Description

This PR addresses some optimizations for logout:

  • Deleted all Core Data managed objects in the background context. The changes would then be saved to the persistent container, and the view context would get these changes merged directly from the persistent container. This ensures no discrepancy between the view context and the background context.
  • Additionally, upon reset, CoreDataManager also triggers a notification for the reset, which causes the existing result controllers to fetch data again. We have places in the dashboard where we refresh data upon storage reset. To avoid refreshing data in the unauthenticated state, a few checks have also been added for orders, Blaze, and dashboard cards.
  • Added a change to DefaultStoresManager to reset sessionManager before updating the state in deauthenticate. This is to avoid an unexpected state where the user is unauthenticated but still has a default store. In [Crash] Attempt to fix crash with magic link login #11373, the AppCoordinator would deauthenticate the app again in this state, triggering an unnecessary reset for CardPresentPaymentAction again.

Steps to reproduce

  • Log in to a test store.
  • Navigate to Menu > Settings > Log out.
  • Confirm logout and check in Xcode console to ensure that there is no more warning about "No processor found for ActionName".
  • Confirm that the authenticator is displayed.
  • Log in again and confirm that all four tabs are loaded as expected.

Testing information

Tested on simulator iPhone 16 Pro iOS 18.0 and confirmed that logout and login work as expected. The app functions normally after logging in again.

Screenshots

N/A


  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

TODO: @itsmeichigo to update the release notes before merging.

Reviewer (or Author, in the case of optional code reviews):

Please make sure these conditions are met before approving the PR, or request changes if the PR needs improvement:

  • The PR is small and has a clear, single focus, or a valid explanation is provided in the description. If needed, please request to split it into smaller PRs.
  • Ensure Adequate Unit Test Coverage: The changes are reasonably covered by unit tests or an explanation is provided in the PR description.
  • Manual Testing: The author listed all the tests they ran, including smoke tests when needed (e.g., for refactorings). The reviewer confirmed that the PR works as expected on all devices (phone/tablet) and no regressions are added.

@itsmeichigo itsmeichigo added the type: task An internally driven task. label Oct 18, 2024
@dangermattic
Copy link
Collaborator

1 Message
📖 This PR is still a Draft: some checks will be skipped.

Generated by 🚫 Danger

@itsmeichigo itsmeichigo marked this pull request as ready for review October 18, 2024 10:13
@wpmobilebot
Copy link
Collaborator

WooCommerce iOS📲 You can test the changes from this Pull Request in WooCommerce iOS by scanning the QR code below to install the corresponding build.

App NameWooCommerce iOS WooCommerce iOS
Build Numberpr14154-0c8f5f0
Version20.7
Bundle IDcom.automattic.alpha.woocommerce
Commit0c8f5f0
App Center BuildWooCommerce - Prototype Builds #11189
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: task An internally driven task.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update CoreDataManager's reset to clear stored objects in background context
3 participants