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

Properly manage multiple concurrent sessions #79

Open
musicog opened this issue Jan 30, 2024 · 2 comments
Open

Properly manage multiple concurrent sessions #79

musicog opened this issue Jan 30, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@musicog
Copy link
Member

musicog commented Jan 30, 2024

Description
Currently, mei-friend tracks all changes to the encoding, as well as most settings, layout options, etc. in the browser's local storage, so that the application may be reinstated after browser shutdown, etc. Unfortunately, this means that there is currently a baked-in assumption of a single current session. It would clearly be preferable if multiple concurrent sessions (e.g., working on multiple MEI files simultaneously in separate tabs) could be accommodated.

Proposed solution

  • Generate a unique identifier for each new session, defined when an encoding file is opened.
  • Prefix all local storage variables with this identifier, allowing multiple versions to exist in local storage simultaneously.
  • Use the browser's session storage to store the current session identifier.
  • When loading MEI friend, check for the existence of a session identifier in the session storage. I
    • if it exists, check for the existence of corresponding items in the local storage and load them
    • if it doesn't exist, or corresponding items don't exist in the local storage, offer the user a selection of known sessions (also stored in local storage) to load, or the option to start a new session.

This solution would allow multiple sessions to co-exist on the same machine.

Additional context
Whenever anything is written to local storage, it would need to be prefixed with the new session variable.
Note that local storage is only capable of storing strings, therefore serialization needs to take place.

@musicog musicog added the enhancement New feature or request label Jan 30, 2024
@wergo
Copy link
Member

wergo commented Feb 14, 2024

How shall we handle sessions initiated through a link with URL parameters?

Clicking on such a link will create a new window/tab and should therefore always ask for user input. If a previous session is selected to be restored, the URL parameter values should not be overridden.

@maxrothman
Copy link

If all you want is to allow multiple sessions to not step on each others’ toes, a better option than prefixing might be sessionStorage, which works identically to localStorage but is scoped to the tab and is cleared when the tab exits.

This raises another interesting issue with multiple sessions though: when a new tab is opened, with sessionStorage it would always start fresh. But even if this is not desired, when a new tab is opened, which session should it use?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants