Fix clicking MXID in timeline going to matrix.to (#11263)

* Fix clicking MXID in timeline going to matrix.to

* Add tests

* Increase coverage
This commit is contained in:
Michael Telatynski 2023-07-14 11:55:55 +01:00 committed by GitHub
parent 3a784c71e8
commit cb592dc709
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 50 additions and 7 deletions

View file

@ -139,7 +139,6 @@ export const options: Opts = {
const permalink = parsePermalink(href);
if (permalink?.userId) {
return {
// @ts-ignore see https://linkify.js.org/docs/options.html
click: function (e: MouseEvent) {
onUserClick(e, permalink.userId!);
},
@ -150,7 +149,6 @@ export const options: Opts = {
if (localHref !== href) {
// it could be converted to a localHref -> therefore handle locally
return {
// @ts-ignore see https://linkify.js.org/docs/options.html
click: function (e: MouseEvent) {
e.preventDefault();
window.location.hash = localHref;
@ -165,17 +163,15 @@ export const options: Opts = {
}
case Type.UserId:
return {
// @ts-ignore see https://linkify.js.org/docs/options.html
click: function (e: MouseEvent) {
const userId = parsePermalink(href)?.userId;
const userId = parsePermalink(href)?.userId ?? href;
if (userId) onUserClick(e, userId);
},
};
case Type.RoomAlias:
return {
// @ts-ignore see https://linkify.js.org/docs/options.html
click: function (e: MouseEvent) {
const alias = parsePermalink(href)?.roomIdOrAlias;
const alias = parsePermalink(href)?.roomIdOrAlias ?? href;
if (alias) onAliasClick(e, alias);
},
};