This commit is contained in:
Ian Philips 2022-08-03 15:05:19 -06:00
parent d2ed985f2a
commit e6ace54adb

View File

@ -245,7 +245,7 @@ export function GroupChatInBubble(props: {
<GroupChatNotificationsIcon <GroupChatNotificationsIcon
group={group} group={group}
privateUser={privateUser} privateUser={privateUser}
setAsSeen={shouldShowChat} shouldSetAsSeen={shouldShowChat}
/> />
)} )}
</button> </button>
@ -256,32 +256,31 @@ export function GroupChatInBubble(props: {
function GroupChatNotificationsIcon(props: { function GroupChatNotificationsIcon(props: {
group: Group group: Group
privateUser: PrivateUser privateUser: PrivateUser
setAsSeen: boolean shouldSetAsSeen: boolean
}) { }) {
const { privateUser, group, setAsSeen } = props const { privateUser, group, shouldSetAsSeen } = props
const preferredNotificationsForThisGroup = useUnseenPreferredNotifications( const preferredNotificationsForThisGroup = useUnseenPreferredNotifications(
privateUser, privateUser,
{ {
customHref: `/group/${group.slug}`, customHref: `/group/${group.slug}`,
} }
) )
// Set notification as seen if our current page is equal to the isSeenOnHref property
useEffect(() => { useEffect(() => {
preferredNotificationsForThisGroup.forEach((notification) => { preferredNotificationsForThisGroup.forEach((notification) => {
if ( if (
(setAsSeen && notification.isSeenOnHref?.includes('chat')) || (shouldSetAsSeen && notification.isSeenOnHref?.includes('chat')) ||
// old style chat notif that simply ended with the group slug // old style chat notif that simply ended with the group slug
notification.isSeenOnHref?.endsWith(group.slug) notification.isSeenOnHref?.endsWith(group.slug)
) { ) {
setNotificationsAsSeen([notification]) setNotificationsAsSeen([notification])
} }
}) })
}, [group.slug, preferredNotificationsForThisGroup, setAsSeen]) }, [group.slug, preferredNotificationsForThisGroup, shouldSetAsSeen])
return ( return (
<div <div
className={ className={
preferredNotificationsForThisGroup.length > 0 && !setAsSeen preferredNotificationsForThisGroup.length > 0 && !shouldSetAsSeen
? 'absolute right-4 top-4 h-3 w-3 rounded-full border-2 border-white bg-red-500' ? 'absolute right-4 top-4 h-3 w-3 rounded-full border-2 border-white bg-red-500'
: 'hidden' : 'hidden'
} }