-
Notifications
You must be signed in to change notification settings - Fork 2
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
Design WebView state #222
Comments
One example of webview state would be a list of open texts on a text collection webview |
What is the advantage of implementing and using this over local storage or session storage? I guess if the state needs to be saved between devices for a user? |
Honestly I'm not sure However, I believe having state be a feature on the webview would allow state to be modified by the web view provider (and, if we so decide, maybe other things as well). The main things I think about here are specifying some state when first loading the web view (e.g. telling the webview which texts to load in its text collection) and making version updates to webview state without forcing the webview itself to support old versions of its state (the provider could transform the data on load to make the code simpler). |
"We also want the text in the title bar of the webview to be updated dynamically. Right now I this is just static text." split off to #445 |
Created simple implementation issue #472. This design is now for expanded functionality if we want it. Like updating the state from the webview provider anytime. Not sure we need that, but this is here. |
As a follow-up to #472 (PR #545), it may be good to rework webview state to be attached directly to the However, I believe this may require creating a synchronous-access |
This is the reason I didn't do it this way at least for now. There was a requirement for this API to be synchronous, and the dock layout is stored as a promise with the comment:
We're also a little loose in how we handle some async calls (i.e., we don't always await the results) in this code. For example:
In other languages when you start getting loose with multi-threading you start to have weird bugs and problems that are hard to diagnose. I don't have enough experience here to say how well those things translate, but it seemed safer to have a totally separately, synchronous (by design) service to saving/loading state. The code to cleanup old values wasn't that hard to write, and it isn't that long, so it seemed better to go that route than to try to be hacky with async concepts here. If/when we get to a point where working with the dock layout is safely synchronous, then changing how we store web view state makes sense to me. I would probably not want to change where we store web state until then. |
Note: I added synchronous access to the dock layout in #445 |
As a user, I want my tabs to stay the same between refreshes and restarts so I can pick up where I left off anytime.
As an extension developer, I want the platform to keep track of a set of data that describes the state of each of my webviews so I can keep the webview the same between sessions and such. I want to be able to set this data when the platform asks for a new webview so I can pull up the webview in whatever state is appropriate for the situation.
Created from #177: Add some way for webviews to keep their own state that papi persists and passes to them when the webview loads. For example, clicking a button can increase a counter, but we want it to persist between refreshes and restarts. This could probably be tied to the webview's id in some way. Maybe a map could be stored in
web-view.service.ts
.We could probably make a hook for React webviews that wraps this state in an exact mirror to
useState
.This could be similar to VSCode's webview state. They basically just let the webview set state synchronously and send messages in the background to asynchronously persist the updates. We might be able to do it fully synchronously, though, since the renderer shares origin with the iframes.
WebView State design
Settings & State Design Doc
The text was updated successfully, but these errors were encountered: