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 method to clear persistent storage #142

Merged

Conversation

donmccurdy
Copy link
Contributor

@donmccurdy donmccurdy commented May 3, 2022

Possible solution to an issue we discussed briefly in Discord — our application registers an extension, and displays a button allowing users to save their changes to a file. We enable persistent storage in case the page crashes or reloads before changes have been saved. In some cases the user may decide not to save the changes they've made since the last save, in which case we need a way to clear persistent storage.

I've tried just clearing all localstorage entries with the right prefix and then reloading, but then theatre.js is doing one last commit to localstorage before the page reloads and the cache persists. This PR would expose a new method, studio.clearPersistentStorage(), which could be used by userland code or extensions.

This contribution is funded by The New York Times.

@vercel
Copy link

vercel bot commented May 3, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
theatre-playground ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Mar 8, 2023 at 11:04AM (UTC)

@vezwork
Copy link
Contributor

vezwork commented Jun 10, 2022

Thanks for the PR @donmccurdy, also thanks for the clear comments and code.

Update: we are discussing this area of the API internally. We want to keep this PR open during that process. I can't currently give you a timeline, but will keep you updated as we make progress.

@vezwork vezwork added the ⏸ on hold Blocked by internal discussion label Jun 10, 2022
@donmccurdy
Copy link
Contributor Author

@vezwork just following up here — we're still looking for some way to clear the cache. Would welcome even an "experimental" API for that purpose!

@AriaMinaei AriaMinaei disabled auto-merge March 8, 2023 11:19
@AriaMinaei AriaMinaei merged commit 1bb8099 into theatre-js:main Mar 8, 2023
7 checks passed
@AriaMinaei
Copy link
Member

Thanks @donmccurdy! Just note that I've renamed the API to: studio.__experimental.__experimental_clearPersistentStorage(persistenceKey)

@donmccurdy donmccurdy deleted the feat/clear-persistent-storage branch March 8, 2023 21:00
@craigthings
Copy link

craigthings commented Jul 26, 2023

I wonder if an alternative to this would be to add a config param when initializing studio to disable persistent storage? There are some cases I can imagine where storing and restoring state would be managed in userland.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⏸ on hold Blocked by internal discussion
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants