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

Peeking unknown rooms #3

Closed
wants to merge 9 commits into from
Closed

Peeking unknown rooms #3

wants to merge 9 commits into from

Conversation

ashfame
Copy link
Member

@ashfame ashfame commented Feb 9, 2023

PR meant for review (not for merge)

@ashfame ashfame requested a review from psrpinto February 9, 2023 12:49
@ashfame ashfame self-assigned this Feb 9, 2023
Copy link
Member

@psrpinto psrpinto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking great, looking forward to having this feature in hydrogen! Well done!

I noticed that when viewing large rooms there is a long delay between the UI first rendering and the timeline appearing, so I think we would probably need to show a loading state before the timeline actually renders:

Screen.Recording.2023-02-10.at.15.37.18.mov

src/domain/session/SessionViewModel.js Outdated Show resolved Hide resolved
src/platform/web/ui/session/SessionView.js Outdated Show resolved Hide resolved
src/platform/web/ui/session/room/PeekableRoomView.js Outdated Show resolved Hide resolved
src/domain/session/room/UnknownRoomViewModel.js Outdated Show resolved Hide resolved
src/domain/session/room/UnknownRoomViewModel.js Outdated Show resolved Hide resolved
src/platform/web/ui/session/room/PeekableRoomView.js Outdated Show resolved Hide resolved
@ashfame
Copy link
Member Author

ashfame commented Feb 11, 2023

@psrpinto Thanks for the great suggestions! <3

Could you explain the issue in your screencast? matrix.org doesn't allow previews on their rooms if you are not in the room and hence peeking can't be functional for those rooms. I believe they must have done it to prevent DOS attacks or to improve scaling. How were you able to even trigger the timeline to load for you?

}
try {
this._room = await this._session.loadWorldReadableRoom(this.roomIdOrAlias);
const timeline = await this._room.openTimeline();
Copy link

@bwindels bwindels Feb 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting ... how does this work if you don't already have a fragment of the timeline stored? If I understand things correctly, at this point, the room exists solely in-memory and nothing related has been written to storage, right? So what token do you end up calling /messages with? I might very well be missing something :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually loadWorldReadableRoom() above it does all of that - creates the Room object instance, fetch events from messages endpoint & load it all. You will see that here - https://github.com/Automattic/hydrogen-web/pull/3/files#diff-25d3af8c52953975b54837c62ef3195e1054638339aa9b1a9c1d6bc267cdadc8R962

Copy link
Member

@psrpinto psrpinto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain the issue in your screencast?
How were you able to even trigger the timeline to load for you?

In the screen recording I'm using #matrix:matrix.org as an example (!OGEhHVWSdvArJzumhm:matrix.org). I'm not a member of that room but I think I was a member and then left, that's why the last message on the timeline is @psrpinto:matrix.org left the room.

So that might explain why the timeline renders for me, which would mean that we would have to take that scenario in account.

But what should we do? Should we:

  1. Render the UnknownRoomView and show the latest messages
  2. Don't render the UnknownRoomView and let hydrogen take care of it. Hydrogen already shows the timeline if you left the room, I believe.

At the moment we're in the middle of 1. and 2., where we show the UnknownRoomView with not the most recent messages.

matrix.org doesn't allow previews on their rooms if you are not in the room and hence peeking can't be functional for those rooms.

By "doesn't allow" you mean that you can't call the /messages endpoint for the room if you're not a member?

src/matrix/Session.js Outdated Show resolved Hide resolved
src/platform/web/ui/session/room/PeekableRoomView.js Outdated Show resolved Hide resolved
@psrpinto
Copy link
Member

Hydrogen already shows the timeline if you left the room, I believe.

Actually, on master. if I navigate to !OGEhHVWSdvArJzumhm%3Amatrix.org (#matrix:matrix.org) it shows "You are currently not in !OGEhHVWSdvArJzumhm:matrix.org. Want to join it?", it doesn't render the timeline.

Am I going crazy? I thought I'd seen hydrogen rendering the timeline for rooms you left, with history up to the point you left, and a message in the bottom saying "You left the room".

@ashfame
Copy link
Member Author

ashfame commented Feb 13, 2023

So that might explain why the timeline renders for me, which would mean that we would have to take that scenario in account.

That would be the timeline you saw for an archive room. Unless we choose to forget the room, UnknownRoomView doesn't come into the picture and by then peeking functionality handles it.

By "doesn't allow" you mean that you can't call the /messages endpoint for the room if you're not a member?

Correct! If you try to peek into matrix hq room, you will see console errors stating previews are disabled.

I tried peeking into !OGEhHVWSdvArJzumhm%3Amatrix.org and it was 403: User @p1:synapse.dev:8008 not in room !OGEhHVWSdvArJzumhm:matrix.org, and room previews are disabled which is shown in console as well.

I think you got confused by the archive room timeline view after leaving the room.

@ashfame
Copy link
Member Author

ashfame commented Feb 14, 2023

@psrpinto and I discussed this more and it turns out this happens when you try to peek into a room that you earlier were a member in but not anymore. Weirdly enough matrix.org has room previews disabled if you are trying to peek from another homeserver but if you are logged in with an account on matrix.org, it lets you preview but with this edge case of /messages endpoint acting up. I will continue to look into this.

Also while trying to figure this out, I was happy to learn that back scrolling is functional as is :)

@ashfame ashfame force-pushed the peeking_unknown_rooms branch 5 times, most recently from 579a1c5 to 098067f Compare February 16, 2023 15:05
ashfame and others added 3 commits February 16, 2023 19:10
…nd loading things async and updating view as we do

This shows a spinner on UnknownRoomView stating "checking preview capability" and goes away when done
and if room is world_readable, then renders the timeline with the last 100 messages
@ashfame
Copy link
Member Author

ashfame commented Feb 16, 2023

Created PR on upstream - element-hq#1037 so closing this PR

@ashfame ashfame closed this Feb 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

Successfully merging this pull request may close these issues.

3 participants