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 handle matrix.to links to a specific event (message) #222

Open
kevinaboos opened this issue Oct 31, 2024 · 2 comments
Open

Properly handle matrix.to links to a specific event (message) #222

kevinaboos opened this issue Oct 31, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@kevinaboos
Copy link
Member

kevinaboos commented Oct 31, 2024

These links are special and should be handled via in-app actions rather than by opening them as a regular URL in the system browser.

There is a separate issue for handling matrix.to links to a specific Room, which is easier: #87

Implementation

Currently, Robrix just ignores matrix.to links that are clicked on, as seen in the code here:

// Handle a link being clicked.
if let HtmlLinkAction::Clicked { url, .. } = action.as_widget_action().cast() {
if url.starts_with("https://matrix.to/#/") {
log!("TODO: handle Matrix link internally: {url:?}");
// TODO: show a pop-up pane with the user's profile, or a room preview pane.
//
// There are four kinds of matrix.to schemes:
// See here: <https://github.com/matrix-org/matrix.to?tab=readme-ov-file#url-scheme>
// 1. Rooms: https://matrix.to/#/#matrix:matrix.org
// 2. Rooms by ID: https://matrix.to/#/!cURbafjkfsMDVwdRDQ:matrix.org
// 3. Users: https://matrix.to/#/@matthew:matrix.org
// 4. Messages: https://matrix.to/#/#matrix:matrix.org/$1448831580433WbpiJ:jki.re

Note that issue #84 already covers one specific case of this: links to Users, which should be displayed as a special UserTag widget.

This issue covers one other type of matrix.to links:

  • Specific events, e.g., https://matrix.to/#/#matrix:matrix.org/$1448831580433WbpiJ:jki.re
    • Note that direct links to messages can have other parameters in the URL, such as https://matrix.to/#/!nCULugmcNjxWftdWKg:matrix.org/$5ACiF5sT29-mPyxc3vVviMj4ouaZYHVPMRfzarmso1s?via=matrix.org

Links to a message

We should create a MessageTag widget similar to the RoomTag widget mentioned above, which looks like this in Element:
image

Upon click, we should determine which room the linked message belongs to. If the current user has already joined that room, we should open that room's timeline view and then attempt to jump to the event in that room with the given EventId.
That message should be highlighted temporarily for emphasis.

If the user has not yet joined the room containing that linked message, we should open the same room preview as we do for direct links to the room itself. In this case, I don't think there's any other actions we can take -- but we should investigate whether it's possible to obtain a preview of a specific message without having joined that room.

Important Note: it is a common case for a user to be unable to view a specific message, as it may have occurred before they had the permissions to view messages in that room. So we must handle that error case gracefully; here's what Element shows in that case:
image

Difficulty surrounding timeline focus mode

For this, we need to temporarily create a new timeline that is focused on the specific linked-to event. This is difficult because although the Matrix SDK claims it supports changing the focus mode of a given timeline, it does not actually support that, so we cannot simply re-use an existing timeline for the room containing that event.

Thus, we have to create a new separate timeline instance using TimelineBuilder::with_focus() (using TimelineFocus::Event), and then just use that new timeline instance as a temporary way to preview this Event.

@github-project-automation github-project-automation bot moved this to Ready in Robrix Oct 31, 2024
@kevinaboos kevinaboos changed the title Properly handle matrix.to links for a specific event Properly handle matrix.to links to a specific event (message) Oct 31, 2024
@kevinaboos kevinaboos added enhancement New feature or request help wanted Looking for help from anyone! and removed help wanted Looking for help from anyone! labels Oct 31, 2024
@tyreseluo tyreseluo self-assigned this Nov 7, 2024
@tyreseluo
Copy link
Contributor

tyreseluo commented Nov 7, 2024

@kevinaboos Should we create three different tags for each of them or combine them into one tag and display them in a single tag, since they all look similar?

  1. UserTag Display matrix.to links to a specific user as "user tags" #84
  2. RoomTag Properly handle matrix.to links for Rooms #87
  3. MessageTag Properly handle matrix.to links to a specific event (message) #222

@kevinaboos
Copy link
Member Author

those are three different tags, but of course you can create one underlying view for a "pill" UI element that gets re-used for all three tag types. That would be a good way to implement it.

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
Status: Ready
Development

No branches or pull requests

2 participants