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

Allow simulatenous usage of multiple blocks on the same page #159

Open
9 of 11 tasks
akirk opened this issue Jan 18, 2023 · 4 comments
Open
9 of 11 tasks

Allow simulatenous usage of multiple blocks on the same page #159

akirk opened this issue Jan 18, 2023 · 4 comments
Assignees
Milestone

Comments

@akirk
Copy link
Member

akirk commented Jan 18, 2023

element-hq/hydrogen-web#1045

This description has been added by @psrpinto for context:

At the moment, when there's multiple blocks on a page, opening a session on one of the blocks, closes it on all others. This is intended, since Hydrogen does not allow having the same session open in multiple instances of the client, which could cause data corruption.

I can see three ways to address this issue:

  1. Make hydrogen support having the same session open in multiple clients
  2. Assign a different device id to each block
  3. Assign a different session to each block

The ideal scenario would be 1. since both 2. and 3. will result in the user having to log-in in each block, which is not ideal. Alternatively we could explore ways to workaround this, by "cloning" the session, though my guess is this won't be easy to get right. So I think we should first rule out 1. before attempting 2. or 3.

Concerning 1., at this point it's not clear whether it would be possible to do this in hydrogen. We should check with hydrogen maintainers whether they have considered this possibility, or if they have plans to implement it in the future, and what it would take to achieve this, technically.

There are also implications in what concerns SSO, since when the user gets back to the page at the end of the SSO flow, only one of the blocks should perform SSO completion, with the other blocks probably having to "wait" until SSO completion is done and a session is created.

PRs

@akirk akirk added this to the 0.6 milestone Jan 23, 2023
@psrpinto psrpinto changed the title Add support for multiple blocks on a page Support multiple blocks on the same page Jan 23, 2023
@psrpinto psrpinto self-assigned this Jan 24, 2023
@psrpinto psrpinto changed the title Support multiple blocks on the same page Set device id per block Jan 27, 2023
@psrpinto psrpinto changed the title Set device id per block Allow simulatenous usage of multiple blocks on the same page Feb 2, 2023
@psrpinto
Copy link
Member

psrpinto commented Feb 2, 2023

I've updated the PR title and description to clarify the issue. Feedback welcome @akirk @ashfame.

We have a meeting with hydrogen maintainers on February 13th, where we should be able to clarify 1. (see PR description). I think we should put this issue on hold until then.

@psrpinto psrpinto modified the milestones: 0.6, 0.7 Feb 2, 2023
@ashfame
Copy link
Member

ashfame commented Feb 2, 2023

Yep, Agree!

@psrpinto psrpinto assigned psrpinto and unassigned psrpinto Feb 8, 2023
@psrpinto
Copy link
Member

psrpinto commented Feb 14, 2023

As mentioned above, we had a call with hydrogen maintainers where we discussed potential strategies to implement simultaneous usage of the same session. Potential strategies would be:

  1. multiple view models but just one client → without iframe
  2. master/slave approach to sync where over a broadcastchannel, the master tab/iframe runs sync and would send which room ids should resync their in-memory state with storage and emit an update.
    • biggest difficulty would be to not have if (master) {} if (slave) {} all over the place, e.g. to only replace some abstractions and have it be somewhat transparent for the rest of the code.
    • for timeline we could communicate if (and how many and which ids) of events were added and you read those again if the timeline is open in the slave room.

Considering 1. would not allow multiple tabs (only multiple instances in the same page), but 2. would, we should attempt 2. instead. We can explore 1. if 2. ends up not being feasible.

@psrpinto
Copy link
Member

psrpinto commented Mar 2, 2023

We've now made a proposal to implement this feature in Hydrogen, and created a ticket to track it.

@ashfame ashfame modified the milestones: 0.7, 1.0 Mar 16, 2023
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

No branches or pull requests

3 participants