Fix Ban command renderer giving useless results.#1120
Conversation
🦋 Changeset detectedLatest commit: fdc9690 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
| export function matrixToPermalink(roomIdOrAlias: string, viaServer: string): string { | ||
| return `https://matrix.to/#/${encodeURIComponent(roomIdOrAlias)}?via=${encodeURIComponent( | ||
| viaServer | ||
| )}`; | ||
| } |
There was a problem hiding this comment.
You should use the MatrixRoomID, MatrixRoomAlias or Permalinks utilities from matrix-basic-types for this.
| /** | ||
| * Build a matrix.to permalink for a room id or alias using the bot's homeserver derived | ||
| * from the provided client MXID. | ||
| */ | ||
| export function matrixToPermalinkFromClientUser( | ||
| roomIdOrAlias: string, | ||
| clientUserID: StringUserID | ||
| ): string { | ||
| const via = userServerName(clientUserID); | ||
| return matrixToPermalink(roomIdOrAlias, via); | ||
| } |
There was a problem hiding this comment.
Similarly there is MatrixUserID and Permalinks
| import expect from "expect"; | ||
| import { matrixToPermalink } from "../../../src/utils"; | ||
|
|
||
| describe("matrixToPermalink", function () { | ||
| it("builds a matrix.to link with a single via", function () { | ||
| const room = "!wJbHKdEdDUKQRGGImO:feline.support"; | ||
| const via = "feline.support"; | ||
| const result = matrixToPermalink(room, via); | ||
| expect(result).toBe( | ||
| `https://matrix.to/#/${encodeURIComponent(room)}?via=${encodeURIComponent( | ||
| via | ||
| )}` | ||
| ); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
No need for this if you use matrix-basic-types mew
| .map((room) => MatrixRoomIDPresentationType.wrap(room)), | ||
| .map((room) => | ||
| StringPresentationType.wrap( | ||
| matrixToPermalinkFromClientUser(room.toRoomIDOrAlias(), clientUserID) | ||
| ) | ||
| ), |
There was a problem hiding this comment.
You could use room.toPermalink() i think?
| .map((room) => MatrixRoomIDPresentationType.wrap(room)), | ||
| .map((room) => | ||
| StringPresentationType.wrap( | ||
| matrixToPermalinkFromClientUser(room.toRoomIDOrAlias(), clientUserID) | ||
| ) | ||
| ), |
There was a problem hiding this comment.
I don't know if this is a good idea. Some clients will show this as a pill yes, But the presentation renderer for MatrixRoomID should really be fixed if it isn't forming pills that clients like.
There was a problem hiding this comment.
It isnt forming ANYTHING. its spitting bare room IDs and thats it. This PR improves that by spitting bare matrix.to links something clients atleast handle. Atleast Element Web does.
There was a problem hiding this comment.
It isnt forming ANYTHING. its spitting bare room IDs and thats it. This PR improves that by spitting bare matrix.to links something clients atleast handle. Atleast Element Web does.
In that case, the problem just is simply that when rendering the suggestions to matrix we use the plain text renderer instead of the DeadDocument one
Fixes: #730
Fixes: #551