Skip to content

Commit

Permalink
Merge branch 'notificationbody' into levitating
Browse files Browse the repository at this point in the history
* notificationbody:
  add message body to notifications
  • Loading branch information
LevitatingBusinessMan committed Nov 30, 2024
2 parents a142630 + 1012c07 commit 12ea60a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/app/pages/client/ClientNonUIFeatures.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,17 +146,19 @@ function MessageNotifications() {
roomName,
roomAvatar,
username,
message,
}: {
roomName: string;
roomAvatar?: string;
username: string;
roomId: string;
eventId: string;
message: string;
}) => {
const noti = new window.Notification(roomName, {
icon: roomAvatar,
badge: roomAvatar,
body: `New inbox notification from ${username}`,
body: `From ${username}: ${message}`,
silent: true,
});

Expand All @@ -178,7 +180,7 @@ function MessageNotifications() {
}, []);

useEffect(() => {
const handleTimelineEvent: RoomEventHandlerMap[RoomEvent.Timeline] = (
const handleTimelineEvent: RoomEventHandlerMap[RoomEvent.Timeline] = async (
mEvent,
room,
toStartOfTimeline,
Expand Down Expand Up @@ -215,6 +217,8 @@ function MessageNotifications() {
if (showNotifications && Notification.permission === 'granted') {
const avatarMxc =
room.getAvatarFallbackMember()?.getMxcAvatarUrl() ?? room.getMxcAvatarUrl();
if (mEvent.isEncrypted()) await mEvent.getDecryptionPromise();
let content = mEvent.getContent();
notify({
roomName: room.name ?? 'Unknown',
roomAvatar: avatarMxc
Expand All @@ -223,6 +227,7 @@ function MessageNotifications() {
username: getMemberDisplayName(room, sender) ?? getMxIdLocalPart(sender) ?? sender,
roomId: room.roomId,
eventId,
message: content.body,
});
}

Expand Down

0 comments on commit 12ea60a

Please sign in to comment.