project-robius / project-robius/robrix

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

Open
#222 2 comments 0 reactions 1 assignee View on GitHub

@tyreseluo is already working on this.

Since Nov 7, 2024.

enhancement
Dominant language
Rust
Stars
487
Forks
68
Avg merge
1h 22m
Merged PRs (30d)
54

Description

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: https://github.com/project-robius/robrix/blob/61f49943b3bb89161dfca26c8cfaec98705f1f42/src/home/room_screen.rs#L857-L868

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.