diff --git a/src/components/notifications-feed/index.tsx b/src/components/notifications-feed/index.tsx index 85ef6e6a0..8a91655a0 100644 --- a/src/components/notifications-feed/index.tsx +++ b/src/components/notifications-feed/index.tsx @@ -87,7 +87,8 @@ export class Container extends React.Component { } renderError() { - return
{'this.props.error'}
; + const { error } = this.props; + return error ?
{error}
: null; } render() { @@ -103,9 +104,9 @@ export class Container extends React.Component {
    {notifications.length > 0 && this.renderNotifications()}
- {notifications.length === 0 && !loading && this.renderNoNotifications()} + {notifications.length === 0 && !loading && !error && this.renderNoNotifications()} {loading && this.renderLoading()} - {error && !loading && this.renderError()} + {error && this.renderError()}
diff --git a/src/lib/chat/matrix/chat-message.ts b/src/lib/chat/matrix/chat-message.ts index 57abf2e8a..bcabd4e54 100644 --- a/src/lib/chat/matrix/chat-message.ts +++ b/src/lib/chat/matrix/chat-message.ts @@ -154,8 +154,8 @@ export async function mapEventToNotification(event) { }, }; - if (type === 'm.room.message') { - const mentions = extractMentionsFromBody(content.body); + if (type === 'm.room.message' && content?.body) { + const mentions = content.body ? extractMentionsFromBody(content.body) : []; if (mentions.length > 0) { return { ...baseNotification, @@ -210,7 +210,7 @@ export async function mapEventToNotification(event) { function extractMentionsFromBody(body: string) { const mentionRegex = /@\[.*?\]\(user:(.*?)\)/g; - const matches = [...body.matchAll(mentionRegex)]; + const matches = [...body?.matchAll(mentionRegex)]; return matches.map((match) => match[1]); } diff --git a/src/store/notifications/saga.ts b/src/store/notifications/saga.ts index 9ac3f5982..00b1ebdeb 100644 --- a/src/store/notifications/saga.ts +++ b/src/store/notifications/saga.ts @@ -14,6 +14,7 @@ export function* fetchNotifications() { yield put(setNotifications(notificationsWithSenders)); } catch (error: any) { + console.error('Error fetching notifications:', error); yield put(setError(error.message)); } finally { yield put(setLoading(false));