Skip to content

Properly init in-memory usage when restoring the state #610

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

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

Conversation

AdamGrzybkowski
Copy link
Contributor

Closes #609

Description

When the "Don't keep activities" is ON, the Quick Editor state won't properly display the data inside. It's caused by a timing issue. The QuickEditorContainer.getInstance().useInMemoryTokenStorage() that is called in the DisposableEffect is invoked after the NavController starts the restored destination, so the ViewModel and its dependencies don't use the in-memory storage as they should.

Moving the DisposableEffect to a Composable higher up in the hierarchy fixes this timing issue.

Before After
state_before state_after

Testing Steps

  1. Enable Developer Options on your device
  2. Launch the demo app
  3. Move to the Avatar update tab
  4. Paste in your WP token and select the checkbox next to it. You can also add it to secrets.properties file with name demo-app.bearer.token.
  5. Tap the avatar to launch the QE
  6. Tap on the View Profile
  7. Go back with a system button or a gesture
  8. Confirm the QE is restored and no errors are visible

When restoring the state after the activity got killed, the NavController would immidiately launch the previous destination
even before running the DisposableEffect. Moving the effect up fixes this timing issue.
@AdamGrzybkowski AdamGrzybkowski added Bug Something isn't working [Feature] Gravatar-Quickeditor Gravatar Quick Editor module labels Apr 18, 2025
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Apr 18, 2025

📲 You can test the changes from this Pull Request in Gravatar Demo by scanning the QR code below to install the corresponding build.
App NameGravatar Demo
Commit78837cc
Direct Downloadgravatar-demo-prototype-build-pr610-78837cc.apk

Copy link
Contributor

@etoledom etoledom left a comment

Choose a reason for hiding this comment

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

I was able to reproduce the issue in trunk, and these changes fixes it 🎉

I also saw another problem where the profile card wasn't showing when opening the QE with a given token, but this also seem to have been fixed with these changes.

This last issue I wasn't to reproduce it again in trunk, so I can't get a video now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working [Feature] Gravatar-Quickeditor Gravatar Quick Editor module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Session expired" after re-opening the QuickEditor
3 participants