From decac58a18fbe3d2f841bed24dc643a09511925a Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 20 Feb 2023 10:29:33 +0000 Subject: [PATCH] Better type guard parseTopicContent (#3165) --- src/content-helpers.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/content-helpers.ts b/src/content-helpers.ts index 88bcd90ef..6790886f2 100644 --- a/src/content-helpers.ts +++ b/src/content-helpers.ts @@ -202,6 +202,9 @@ export type TopicState = { export const parseTopicContent = (content: MRoomTopicEventContent): TopicState => { const mtopic = M_TOPIC.findIn(content); + if (!Array.isArray(mtopic)) { + return { text: content.topic }; + } const text = mtopic?.find((r) => !isProvided(r.mimetype) || r.mimetype === "text/plain")?.body ?? content.topic; const html = mtopic?.find((r) => r.mimetype === "text/html")?.body; return { text, html };