Skip to content

Commit decac58

Browse files
authored
Better type guard parseTopicContent (#3165)
1 parent 1a91ba5 commit decac58

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/content-helpers.ts

+3
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,9 @@ export type TopicState = {
202202

203203
export const parseTopicContent = (content: MRoomTopicEventContent): TopicState => {
204204
const mtopic = M_TOPIC.findIn<MTopicContent>(content);
205+
if (!Array.isArray(mtopic)) {
206+
return { text: content.topic };
207+
}
205208
const text = mtopic?.find((r) => !isProvided(r.mimetype) || r.mimetype === "text/plain")?.body ?? content.topic;
206209
const html = mtopic?.find((r) => r.mimetype === "text/html")?.body;
207210
return { text, html };

0 commit comments

Comments
 (0)