Skip to content

Commit

Permalink
Updated feed notification types;
Browse files Browse the repository at this point in the history
  • Loading branch information
stef-coenen committed Jan 4, 2024
1 parent a274e71 commit c33425f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
9 changes: 8 additions & 1 deletion packages/owner-app/src/sw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ const OWNER_FOLLOWER_TYPE_ID = '2cc468af-109b-4216-8119-542401e32f4d';
const OWNER_CONNECTION_REQUEST_TYPE_ID = '8ee62e9e-c224-47ad-b663-21851207f768';
const OWNER_CONNECTION_ACCEPTED_TYPE_ID = '79f0932a-056e-490b-8208-3a820ad7c321';

const FEED_NEW_CONTENT_TYPE_ID = 'ad695388-c2df-47a0-ad5b-fc9f9e1fffc9';
const FEED_NEW_REACTION_TYPE_ID = '37dae95d-e137-4bd4-b782-8512aaa2c96a';

const titleFormer = (payload: NotificationData) => `${payload.appDisplayName || 'Homebase'}`;

const bodyFormer = (payload: NotificationData, existingNotifications: Notification[]) => {
Expand All @@ -56,7 +59,11 @@ const bodyFormer = (payload: NotificationData, existingNotifications: Notificati
payload.appDisplayName
}`;
} else if (payload.options.appId === FEED_APP_ID) {
return `${payload.senderId} posted to your feed`;
if (payload.options.typeId === FEED_NEW_CONTENT_TYPE_ID) {
return `${payload.senderId} posted to your feed`;
} else if (payload.options.typeId === FEED_NEW_REACTION_TYPE_ID) {
return `${payload.senderId} reacted to your post`;
}
}

return `${payload.senderId} sent you a notification via ${payload.appDisplayName}`;
Expand Down
11 changes: 9 additions & 2 deletions packages/owner-app/src/templates/Notifications/Notifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ const NotificationGroup = ({
}
>
<Toast
// title={notification.options.tagId}
// title={notification.options.typeId}
title={titleFormer(appName)}
// Keeping the hidden ones short
body={ellipsisAtMaxChar(
Expand Down Expand Up @@ -229,6 +229,9 @@ const OWNER_FOLLOWER_TYPE_ID = '2cc468af-109b-4216-8119-542401e32f4d';
const OWNER_CONNECTION_REQUEST_TYPE_ID = '8ee62e9e-c224-47ad-b663-21851207f768';
const OWNER_CONNECTION_ACCEPTED_TYPE_ID = '79f0932a-056e-490b-8208-3a820ad7c321';

const FEED_NEW_CONTENT_TYPE_ID = 'ad695388-c2df-47a0-ad5b-fc9f9e1fffc9';
const FEED_NEW_REACTION_TYPE_ID = '37dae95d-e137-4bd4-b782-8512aaa2c96a';

const titleFormer = (appName: string) => `${appName}`;

const bodyFormer = (payload: PushNotification, hasMultiple: boolean, appName: string) => {
Expand All @@ -246,7 +249,11 @@ const bodyFormer = (payload: PushNotification, hasMultiple: boolean, appName: st
} else if (payload.options.appId === CHAT_APP_ID) {
return `${payload.senderId} sent you ${hasMultiple ? 'multiple messages' : 'a message'}`;
} else if (payload.options.appId === FEED_APP_ID) {
return `${payload.senderId} posted to your feed`;
if (payload.options.typeId === FEED_NEW_CONTENT_TYPE_ID) {
return `${payload.senderId} posted to your feed`;
} else if (payload.options.typeId === FEED_NEW_REACTION_TYPE_ID) {
return `${payload.senderId} reacted to your post`;
}
}

return `${payload.senderId} sent you a notification via ${appName}`;
Expand Down

0 comments on commit c33425f

Please sign in to comment.