From 8bc5b6118038705f125fd1463f18e731a5934d29 Mon Sep 17 00:00:00 2001 From: abyxcos Date: Mon, 3 Oct 2022 10:49:57 -0400 Subject: [PATCH] Fix our replies being flagged as replies. We would get undefined back if both no relation existed and there was no rel_type field. --- hummingbird_ajax.js | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/hummingbird_ajax.js b/hummingbird_ajax.js index 6ba671f..978fc4b 100644 --- a/hummingbird_ajax.js +++ b/hummingbird_ajax.js @@ -239,21 +239,20 @@ function parseMessageEvents(events, room) { // format: "org.matrix.custom.html" // Check if we have any edits or replies. - switch (e.content['m.relates_to']?.rel_type) { - case undefined: - // No relation exists. - break - case 'm.replace': - m.edit = e.content['m.relates_to'].event_id - // Manually merge the new message as someone may have changed the type. - m.type = e.content['m.new_content'].msgtype - m.body = e.content['m.new_content'].formatted_body || - e.content['m.new_content'].formatted_body - break - case 'net.maunium.reply': - default: - m.reply = e.content['m.relates_to']['m.in_reply_to'].event_id - break + if (e.content['m.relates_to']) { + switch (e.content['m.relates_to'].rel_type) { + case 'm.replace': + m.edit = e.content['m.relates_to'].event_id + // Manually merge the new message as someone may have changed the type. + m.type = e.content['m.new_content'].msgtype + m.body = e.content['m.new_content'].formatted_body || + e.content['m.new_content'].formatted_body + break + case 'net.maunium.reply': + default: + m.reply = e.content['m.relates_to']['m.in_reply_to'].event_id + break + } } break -- 2.38.5