From dd15a058ee11fe75a4c4015fb85ee0d40457bf5c Mon Sep 17 00:00:00 2001 From: 10G Meow <10gmeow@gmail.com> Date: Sun, 9 Apr 2023 14:53:16 +0300 Subject: [PATCH] fix urdu sender name and object key check --- src/assets/translations/ug.json | 2 +- src/components/messages/messageMixin.js | 33 ++++++++++++++----------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/assets/translations/ug.json b/src/assets/translations/ug.json index be80bdb..91adf6b 100644 --- a/src/assets/translations/ug.json +++ b/src/assets/translations/ug.json @@ -29,7 +29,7 @@ "download_progress": "{پىرسەنت}% چۈشۈرۈلدى", "edited": "تەھرىرلەندى", "file_prefix": "ھۆججەت ", - "user_said": "قوللانغۇچى سۆزلىدى:", + "user_said": "{user} سۆزلىدى:", "user_left": "قوللانغۇچى مۇنازىرىدىن چېكىندى", "user_joined": "قوللانغۇچى مۇنازىرىغا قاتناشتى", "user_was_invited": "قوللانغۇچى مۇنازىرە ئۆيىگە تەكلىپ قىلىندى...", diff --git a/src/components/messages/messageMixin.js b/src/components/messages/messageMixin.js index e1c9046..55c5aa4 100644 --- a/src/components/messages/messageMixin.js +++ b/src/components/messages/messageMixin.js @@ -98,13 +98,17 @@ export default { const relatesTo = this.event.getWireContent()["m.relates_to"]; if (relatesTo && relatesTo["m.in_reply_to"]) { const content = this.event.getContent(); - const lines = content.body.split("\n").reverse(); - while (lines.length && !lines[0].startsWith("> ")) lines.shift(); - // Reply fallback has a blank line after it, so remove it to prevent leading newline - if (lines[0] === "") lines.shift(); - const text = lines[0] && lines[0].replace(/^> (<.*> )?/g, ""); - if (text) { - return text; + console.log('content') + console.log(content) + if ('body' in content) { + const lines = content.body.split("\n").reverse() || []; + while (lines.length && !lines[0].startsWith("> ")) lines.shift(); + // Reply fallback has a blank line after it, so remove it to prevent leading newline + if (lines[0] === "") lines.shift(); + const text = lines[0] && lines[0].replace(/^> (<.*> )?/g, ""); + if (text) { + return text; + } } if (this.inReplyToEvent) { @@ -122,13 +126,14 @@ export default { const relatesTo = this.event.getWireContent()["m.relates_to"]; if (relatesTo && relatesTo["m.in_reply_to"]) { const content = this.event.getContent(); - - // Remove the new text and strip "> " from the old original text - const lines = content.body.split("\n"); - while (lines.length && lines[0].startsWith("> ")) lines.shift(); - // Reply fallback has a blank line after it, so remove it to prevent leading newline - if (lines[0] === "") lines.shift(); - return lines.join("\n"); + if ('body' in content) { + // Remove the new text and strip "> " from the old original text + const lines = content.body.split("\n"); + while (lines.length && lines[0].startsWith("> ")) lines.shift(); + // Reply fallback has a blank line after it, so remove it to prevent leading newline + if (lines[0] === "") lines.shift(); + return lines.join("\n"); + } } return this.event.getContent().body; },