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

Add local_storage #233

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

sfc-gh-jcarroll
Copy link
Collaborator

@sfc-gh-jcarroll sfc-gh-jcarroll commented Jul 3, 2024

Add a local_storage extra for easier interaction with browser localStorage

It's still a bit buggy at times, I get periodic "app resets" (the session_state still exists but widget values get reset) which I can't explain. Like everything gets unmounted. May have to do with the way st_js updates very quickly and some race condition.

Copy link

netlify bot commented Jul 3, 2024

Deploy Preview for phenomenal-crepe-0effec ready!

Name Link
🔨 Latest commit ae446bb
🔍 Latest deploy log https://app.netlify.com/sites/phenomenal-crepe-0effec/deploys/668895f2c07cc70008c9017d
😎 Deploy Preview https://deploy-preview-233--phenomenal-crepe-0effec.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@sfc-gh-jcarroll sfc-gh-jcarroll requested a review from blackary July 3, 2024 22:51
@bhargavmodak
Copy link

I've tried this to test in an application for my own testing, and I think it would be useful for your reference before this is merged:


How to test:

You can either log-in directly with the above deployment (or clone and deploy yourself).

Note

The Google OAuth Consent screen has to be opened in a new tab. This is related to Streamlit Issue #7123: Link redirect. Read more about how I did it in Chapter 2 of the repo above.

  1. After logging in, you should be redirected to the /auth route of the app above. Here I try to save the google session token pair into local storage.
    1. Check the local storage as it processes. You should see st_localstorage_g_session.
  2. Issue 1 occurs here.
  3. If you go into an infinite loop, reload the page. Then it works.
  4. Once you log in, you can look around the app. The /auth route is hidden.
  5. Try to log out.
  6. Issue 2 occurs here.

Issues

ISSUE 1

The processing goes into an infinite loop even if the data has been set in local storage.

  • Check auth.py to see that to prevent the infinite rerun, I check if the data was saved to google storage.
  • The processing is completed in local deployment (localhost:8501). I added delay to test it via Github Codespaces, and a delay of 0.5 via time.sleep() seemed to work on the Github Codespaces deployment of streamlit, but doesn't work in the app above.
  • Need to test with more delays, but I am skeptical if it would work.

ISSUE 2

When logging out, it says 'Bad message format : Bad 'setIn' index # (should be between [0, 1])

  • However, sometimes, for unknown reasons, it does manage to log out.
  • Check out the show_logout() function in utils.py
  • The logout functionality works in (localhost:8501).

I'm assuming both issues are occurring due to the local storage. I've implemented it at st_local_storage.py.

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.

2 participants