forked from mystiq/hydrogen-web
Treat replies to thread as threaded message
This commit is contained in:
parent
337d0726ce
commit
9eeeea47d9
2 changed files with 19 additions and 1 deletions
|
@ -32,7 +32,11 @@ export class BaseEventEntry extends BaseEntry {
|
||||||
}
|
}
|
||||||
|
|
||||||
get isReply() {
|
get isReply() {
|
||||||
return !!this.relation?.["m.in_reply_to"];
|
return !!(this.relation?.["m.in_reply_to"] || this.isThread);
|
||||||
|
}
|
||||||
|
|
||||||
|
get isThread() {
|
||||||
|
return this.relation?.["rel_type"] === "io.element.thread";
|
||||||
}
|
}
|
||||||
|
|
||||||
get isRedacting() {
|
get isRedacting() {
|
||||||
|
|
|
@ -51,6 +51,9 @@ function _createReplyContent(targetId, msgtype, body, formattedBody) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createReplyContent(entry, msgtype, body) {
|
export function createReplyContent(entry, msgtype, body) {
|
||||||
|
if (entry.isThread) {
|
||||||
|
return createThreadContent(entry, msgtype, body);
|
||||||
|
}
|
||||||
// TODO check for absense of sender / body / msgtype / etc?
|
// TODO check for absense of sender / body / msgtype / etc?
|
||||||
const nonTextual = fallbackForNonTextualMessage(entry.content.msgtype);
|
const nonTextual = fallbackForNonTextualMessage(entry.content.msgtype);
|
||||||
const prefix = fallbackPrefix(entry.content.msgtype);
|
const prefix = fallbackPrefix(entry.content.msgtype);
|
||||||
|
@ -72,3 +75,14 @@ export function createReplyContent(entry, msgtype, body) {
|
||||||
const newFormattedBody = formattedFallback + htmlEscape(body);
|
const newFormattedBody = formattedFallback + htmlEscape(body);
|
||||||
return _createReplyContent(entry.id, msgtype, newBody, newFormattedBody);
|
return _createReplyContent(entry.id, msgtype, newBody, newFormattedBody);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function createThreadContent(entry, msgtype, body) {
|
||||||
|
return {
|
||||||
|
msgtype,
|
||||||
|
body,
|
||||||
|
"m.relates_to": {
|
||||||
|
"rel_type": "m.thread",
|
||||||
|
"event_id": entry.id
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue