-
-
Notifications
You must be signed in to change notification settings - Fork 666
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
Provide app.storage.tab #2837
Provide app.storage.tab #2837
Conversation
I am one who always closes all browser tabs asap but I know many people who have like 50+ tabs over weeks who even have to scroll horizontally and just still identify the tab by the fav icon and first letter. I think we need to differentiate here between important, un-recoverable, compact and most importantly serializable data... like a long text someone typed and it would really hurt if it were lost... or the user's avatar we just cached in storage.tab so we don't have to pull it from the database every time. If one could flag such data as "important" then we could transfer it in a configurable intervals from the server to the client and store it next to "__nicegui_tab_id" in the local storage. And when the connection was completely broken (PC shutdown, browser closed etc.) and is then re-established we could just send all this data along with the handshake back to the server and then the server can decide if it can be recovered. |
I would rather like to not do that. Maybe we can leave that it in the hands of the user? I suggest we do:
Maybe later we can add a feature that saves all serializable fields to a file in regular intervals -- and load this on server startup. |
I created #2841 as a feature request for persistence across server restarts. |
Looks great. Two remarks though:
Other than that the Exceptions triggered by auto-index and missing client connection in the unit tests are not yet covered, don't know if you guys aim here for high coverage. See here. |
That should work. |
This pull request picks up on the idea from #2820 (comment) and other discussion around this topic to implement
app.storage.tab
: a volatile storage which keeps a state dictionary as long as the browser tab lives. That means the data survives page reloads and switching urls.It is implemented by storing the dictionary in the memory of the server. To decide which dictionary needs to be accessed the pull request introduces a
client.tab_id
which is automatically set when doing the websocket handshake.ToDos