Implement broadcast message preview (#9762)

This commit is contained in:
Michael Weimann 2022-12-16 12:01:16 +01:00 committed by GitHub
parent 6205c70462
commit 51554399fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 353 additions and 32 deletions

View file

@ -23,11 +23,15 @@ import { _t, sanitizeForTranslation } from "../../../languageHandler";
import { getSenderName, isSelf, shouldPrefixMessagesIn } from "./utils";
import { getHtmlText } from "../../../HtmlUtils";
import { stripHTMLReply, stripPlainReply } from "../../../utils/Reply";
import { VoiceBroadcastChunkEventType } from "../../../voice-broadcast/types";
export class MessageEventPreview implements IPreview {
public getTextFor(event: MatrixEvent, tagId?: TagID, isThread?: boolean): string {
public getTextFor(event: MatrixEvent, tagId?: TagID, isThread?: boolean): string | null {
let eventContent = event.getContent();
// no preview for broadcast chunks
if (eventContent[VoiceBroadcastChunkEventType]) return null;
if (event.isRelation(RelationType.Replace)) {
// It's an edit, generate the preview on the new text
eventContent = event.getContent()["m.new_content"];