Allow opening notifs in new tabs, return newest notifs
This commit is contained in:
parent
93b9ace477
commit
a1e03c3a25
|
@ -32,15 +32,10 @@ export function usePreferredGroupedNotifications(
|
||||||
if (!result.data) return cachedNotifications ?? []
|
if (!result.data) return cachedNotifications ?? []
|
||||||
const notifications = result.data as Notification[]
|
const notifications = result.data as Notification[]
|
||||||
|
|
||||||
const notificationsToShow = getAppropriateNotifications(
|
return getAppropriateNotifications(
|
||||||
notifications,
|
notifications,
|
||||||
privateUser.notificationPreferences
|
privateUser.notificationPreferences
|
||||||
).filter((n) => !n.isSeenOnHref)
|
).filter((n) => !n.isSeenOnHref)
|
||||||
const cachedIds = cachedNotifications?.map((n) => n.id)
|
|
||||||
if (notificationsToShow.some((n) => !cachedIds?.includes(n.id))) {
|
|
||||||
return notificationsToShow
|
|
||||||
}
|
|
||||||
return cachedNotifications
|
|
||||||
}, [
|
}, [
|
||||||
cachedNotifications,
|
cachedNotifications,
|
||||||
privateUser.notificationPreferences,
|
privateUser.notificationPreferences,
|
||||||
|
|
|
@ -47,12 +47,12 @@ import Custom404 from 'web/pages/404'
|
||||||
import { track } from '@amplitude/analytics-browser'
|
import { track } from '@amplitude/analytics-browser'
|
||||||
import { Pagination } from 'web/components/pagination'
|
import { Pagination } from 'web/components/pagination'
|
||||||
import { useWindowSize } from 'web/hooks/use-window-size'
|
import { useWindowSize } from 'web/hooks/use-window-size'
|
||||||
import Router from 'next/router'
|
|
||||||
import { safeLocalStorage } from 'web/lib/util/local'
|
import { safeLocalStorage } from 'web/lib/util/local'
|
||||||
import {
|
import {
|
||||||
getServerAuthenticatedUid,
|
getServerAuthenticatedUid,
|
||||||
redirectIfLoggedOut,
|
redirectIfLoggedOut,
|
||||||
} from 'web/lib/firebase/server-auth'
|
} from 'web/lib/firebase/server-auth'
|
||||||
|
import { SiteLink } from 'web/components/site-link'
|
||||||
|
|
||||||
export const NOTIFICATIONS_PER_PAGE = 30
|
export const NOTIFICATIONS_PER_PAGE = 30
|
||||||
const MULTIPLE_USERS_KEY = 'multipleUsers'
|
const MULTIPLE_USERS_KEY = 'multipleUsers'
|
||||||
|
@ -100,7 +100,8 @@ export default function Notifications(props: { user: User }) {
|
||||||
privateUser={privateUser}
|
privateUser={privateUser}
|
||||||
cachedNotifications={localNotifications}
|
cachedNotifications={localNotifications}
|
||||||
/>
|
/>
|
||||||
) : localNotifications && localNotifications.length > 0 ? (
|
) : localNotificationGroups &&
|
||||||
|
localNotificationGroups.length > 0 ? (
|
||||||
<div className={'min-h-[100vh]'}>
|
<div className={'min-h-[100vh]'}>
|
||||||
<RenderNotificationGroups
|
<RenderNotificationGroups
|
||||||
notificationGroups={localNotificationGroups}
|
notificationGroups={localNotificationGroups}
|
||||||
|
@ -440,7 +441,11 @@ function IncomeNotificationItem(props: {
|
||||||
highlighted && HIGHLIGHT_CLASS
|
highlighted && HIGHLIGHT_CLASS
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<a href={getSourceUrl(notification)}>
|
<div className={'relative'}>
|
||||||
|
<SiteLink
|
||||||
|
href={getSourceUrl(notification) ?? ''}
|
||||||
|
className={'absolute left-0 right-0 top-0 bottom-0 z-0'}
|
||||||
|
/>
|
||||||
<Row className={'items-center text-gray-500 sm:justify-start'}>
|
<Row className={'items-center text-gray-500 sm:justify-start'}>
|
||||||
<div className={'line-clamp-2 flex max-w-xl shrink '}>
|
<div className={'line-clamp-2 flex max-w-xl shrink '}>
|
||||||
<div className={'inline'}>
|
<div className={'inline'}>
|
||||||
|
@ -466,7 +471,7 @@ function IncomeNotificationItem(props: {
|
||||||
</div>
|
</div>
|
||||||
</Row>
|
</Row>
|
||||||
<div className={'mt-4 border-b border-gray-300'} />
|
<div className={'mt-4 border-b border-gray-300'} />
|
||||||
</a>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -655,24 +660,24 @@ function NotificationItem(props: {
|
||||||
highlighted && HIGHLIGHT_CLASS
|
highlighted && HIGHLIGHT_CLASS
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<div
|
<div className={'relative cursor-pointer'}>
|
||||||
className={'cursor-pointer'}
|
<SiteLink
|
||||||
onClick={(event) => {
|
href={getSourceUrl(notification) ?? ''}
|
||||||
event.stopPropagation()
|
className={'absolute left-0 right-0 top-0 bottom-0 z-0'}
|
||||||
Router.push(getSourceUrl(notification) ?? '')
|
onClick={() =>
|
||||||
track('Notification Clicked', {
|
track('Notification Clicked', {
|
||||||
type: 'notification item',
|
type: 'notification item',
|
||||||
sourceType,
|
sourceType,
|
||||||
sourceUserName,
|
sourceUserName,
|
||||||
sourceUserAvatarUrl,
|
sourceUserAvatarUrl,
|
||||||
sourceUpdateType,
|
sourceUpdateType,
|
||||||
reasonText,
|
reasonText,
|
||||||
reason,
|
reason,
|
||||||
sourceUserUsername,
|
sourceUserUsername,
|
||||||
sourceText,
|
sourceText,
|
||||||
})
|
})
|
||||||
}}
|
}
|
||||||
>
|
/>
|
||||||
<Row className={'items-center text-gray-500 sm:justify-start'}>
|
<Row className={'items-center text-gray-500 sm:justify-start'}>
|
||||||
<Avatar
|
<Avatar
|
||||||
avatarUrl={
|
avatarUrl={
|
||||||
|
@ -681,7 +686,7 @@ function NotificationItem(props: {
|
||||||
: sourceUserAvatarUrl
|
: sourceUserAvatarUrl
|
||||||
}
|
}
|
||||||
size={'sm'}
|
size={'sm'}
|
||||||
className={'mr-2'}
|
className={'z-10 mr-2'}
|
||||||
username={
|
username={
|
||||||
questionNeedsResolution ? MANIFOLD_USERNAME : sourceUserUsername
|
questionNeedsResolution ? MANIFOLD_USERNAME : sourceUserUsername
|
||||||
}
|
}
|
||||||
|
@ -697,7 +702,7 @@ function NotificationItem(props: {
|
||||||
<UserLink
|
<UserLink
|
||||||
name={sourceUserName || ''}
|
name={sourceUserName || ''}
|
||||||
username={sourceUserUsername || ''}
|
username={sourceUserUsername || ''}
|
||||||
className={'mr-1 flex-shrink-0'}
|
className={'relative mr-1 flex-shrink-0'}
|
||||||
justFirstName={true}
|
justFirstName={true}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
@ -764,10 +769,8 @@ function QuestionOrGroupLink(props: {
|
||||||
</span>
|
</span>
|
||||||
)
|
)
|
||||||
return (
|
return (
|
||||||
<a
|
<SiteLink
|
||||||
className={
|
className={'relative ml-1 font-bold'}
|
||||||
'ml-1 font-bold hover:underline hover:decoration-indigo-400 hover:decoration-2 '
|
|
||||||
}
|
|
||||||
href={
|
href={
|
||||||
sourceContractCreatorUsername
|
sourceContractCreatorUsername
|
||||||
? `/${sourceContractCreatorUsername}/${sourceContractSlug}`
|
? `/${sourceContractCreatorUsername}/${sourceContractSlug}`
|
||||||
|
@ -792,7 +795,7 @@ function QuestionOrGroupLink(props: {
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{sourceContractTitle || sourceTitle}
|
{sourceContractTitle || sourceTitle}
|
||||||
</a>
|
</SiteLink>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user