-
Notifications
You must be signed in to change notification settings - Fork 40
[Feature] Display matrix.to links to a specific pill. #390
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
[Feature] Display matrix.to links to a specific pill. #390
Conversation
ZhangHanDong
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, no suggestions, lgtm.
As for the naming, actually, you don't need to add "Get" since you are already initiating a Request.
kevinaboos
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work so far, I'm impressed with your code clarity! It's very easy to read, nice job.
I left a few comments below.
One other issue -- I think that caching of RoomPreviews needs to be handled a little bit differently from the other content that we cache (Avatars, UserProfiles). I think we need to re-get a RoomPreview every time a user clicks on an unknown Room link.
- Note: we should also probably save this for a future PR, because this PR only needs to deal with displaying the actual links as special Pill widgets.
So, we don't have to think about what room_preview requests for now? Just show only the pill? |
yes, we can keep this cache for now until we have a unified solution for cache handling. The problem you mentioned is indeed that if a user clicks on an unknown room we should indeed re-fetch the room preview and determine if the unknown room is allowed to be previewed, and if so re-fetch it while displaying the viewed room message. |
Co-authored-by: Kevin Boos <1139460+kevinaboos@users.noreply.github.com>
f5b89a4 to
2850765
Compare
2850765 to
db2dca2
Compare
My apologies, I made a confusing comment. What I meant to say was that:
|
kevinaboos
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, except for the part about handling the Requested status, which needs to be reworked a bit.
Show/set is misleading, these functions are actually related to drawing and populating the content of the pill widgets.
|
Alrighty, I've rewritten most of this PR again. The primary issue that caused our joint misunderstanding is that you imitated the design of HtmlOrPlaintext and Avatar widgets, but those are actually categorically different from the way this special HTML link widget must work. The way you named the functions (and the manner of calling redraw within a draw context) made it seem like they were not draw-time functions, but they actually were. You shouldn't ever need to call redraw in a draw function. These functions are actually used to populate the content of the pill widgets (or the HTML link), so I've renamed them as such and completely reimplemented how they work. Also, a lot of them were public functions which made it seem like they were eligible to be called from external modules in the app, but that's not actually possible because all of the content used to populate the pill/link widgets can only come from within the HTML-parsed context, not from other widgets. I also restored the existing behavior of parsing all bare HTML links as matrix links to ensure that User links can be handled specially (by showing the user profile sliding pane). Not sure how that got removed but it's still important to preserve that behavior. I also made sure to handle the case where a User link is waiting on a fetched User profile, which occurs on a UI In summary, please take a deeper look at my recent two commits to see what kind of code structure and naming style we're looking for. |
|
Thank you so much, Kevin. I'll go over the comments you left and the changes you made to my code section. |
PR content
This PR just extends HtmlLink to create matrix url's special pill and doesn't handle any specific link clicks, they will have a separate PR for processing.
Fixes #84.
RobrixHtmlLinkto handle the normal link and thematrix.tolink, normal links are displayed normally usingHtmlLink.room_preview_cache.rsto deal with blocking of UI threads when room info is requested frequently.PR Problems
Not Fixed yet:
Highlighting @room tags within a message.
This should not be implemented by parsing the @room string from the message text; it should be done by checking the mentions of a given message.
Resolving room aliases within Pill links.
Currently we only immediately handle and display links that have room IDs.
To implement this, we need to create a new MatrixRequest variant for Client::get_room_preview(), which internally will resolve a RoomAliasId and return a preview of the room. We then need to deliver those results back to each Pill widget by using Cx::post_action() to send a new action type containing the RoomPreview; that action should be handled by the matrix pill widget.