fix notification clicking after refactor
This commit is contained in:
parent
3de8df5ab5
commit
f4b81b0ff0
|
@ -30,22 +30,24 @@ function Notification ({ n }) {
|
|||
case 'JobChanged': return <JobChanged n={n} />
|
||||
case 'Reply': return <Reply n={n} />
|
||||
}
|
||||
console.error("__typename not supported:", n.__typename)
|
||||
console.error('__typename not supported:', n.__typename)
|
||||
return null
|
||||
}
|
||||
|
||||
function NotificationLayout ({ children, onClick }) {
|
||||
return (
|
||||
<div className='clickToContext' onClick={(e) => {
|
||||
<div
|
||||
className='clickToContext' onClick={(e) => {
|
||||
if (ignoreClick(e)) return
|
||||
onClick?.(e)
|
||||
}}>
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const defaultOnClick = (n) => () => {
|
||||
const defaultOnClick = (n, router) => () => {
|
||||
if (!n.item.title) {
|
||||
if (n.item.path.split('.').length > COMMENT_DEPTH_LIMIT + 1) {
|
||||
router.push({
|
||||
|
@ -126,7 +128,7 @@ function EarnNotification({ n }) {
|
|||
</div>
|
||||
</div>
|
||||
</NotificationLayout>
|
||||
);
|
||||
)
|
||||
}
|
||||
|
||||
function Invitification ({ n }) {
|
||||
|
@ -172,8 +174,9 @@ function Referral({ n }) {
|
|||
}
|
||||
|
||||
function Votification ({ n }) {
|
||||
const router = useRouter()
|
||||
return (
|
||||
<NotificationLayout onClick={defaultOnClick(n)}>
|
||||
<NotificationLayout onClick={defaultOnClick(n, router)}>
|
||||
<small className='font-weight-bold text-success ml-2'>
|
||||
your {n.item.title ? 'post' : 'reply'} {n.item.fwdUser ? 'forwarded' : 'stacked'} {n.earnedSats} sats{n.item.fwdUser && ` to @${n.item.fwdUser.name}`}
|
||||
</small>
|
||||
|
@ -186,16 +189,16 @@ function Votification({ n }) {
|
|||
<Comment item={n.item} noReply includeParent clickToContext />
|
||||
</RootProvider>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
)}
|
||||
</div>
|
||||
</NotificationLayout>
|
||||
)
|
||||
}
|
||||
|
||||
function Mention ({ n }) {
|
||||
const router = useRouter()
|
||||
return (
|
||||
<NotificationLayout onClick={defaultOnClick(n)}>
|
||||
<NotificationLayout onClick={defaultOnClick(n, router)}>
|
||||
<small className='font-weight-bold text-info ml-2'>
|
||||
you were mentioned in
|
||||
</small>
|
||||
|
@ -207,16 +210,16 @@ function Mention({ n }) {
|
|||
<RootProvider root={n.item.root}>
|
||||
<Comment item={n.item} noReply includeParent rootText={n.__typename === 'Reply' ? 'replying on:' : undefined} clickToContext />
|
||||
</RootProvider>
|
||||
</div>)
|
||||
}
|
||||
</div>)}
|
||||
</div>
|
||||
</NotificationLayout>
|
||||
)
|
||||
}
|
||||
|
||||
function JobChanged ({ n }) {
|
||||
const router = useRouter()
|
||||
return (
|
||||
<NotificationLayout onClick={defaultOnClick(n)}>
|
||||
<NotificationLayout onClick={defaultOnClick(n, router)}>
|
||||
<small className={`font-weight-bold text-${n.item.status === 'ACTIVE' ? 'success' : 'boost'} ml-1`}>
|
||||
{n.item.status === 'ACTIVE'
|
||||
? 'your job is active again'
|
||||
|
@ -230,9 +233,10 @@ function JobChanged({ n }) {
|
|||
}
|
||||
|
||||
function Reply ({ n }) {
|
||||
const router = useRouter()
|
||||
return (
|
||||
<NotificationLayout onClick={defaultOnClick(n)} rootText='replying on:'>
|
||||
<div className="py-2">
|
||||
<NotificationLayout onClick={defaultOnClick(n, router)} rootText='replying on:'>
|
||||
<div className='py-2'>
|
||||
{n.item.title
|
||||
? <Item item={n.item} />
|
||||
: (
|
||||
|
@ -241,8 +245,7 @@ function Reply({ n }) {
|
|||
<Comment item={n.item} noReply includeParent clickToContext rootText='replying on:' />
|
||||
</RootProvider>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
)}
|
||||
</div>
|
||||
</NotificationLayout>
|
||||
)
|
||||
|
@ -301,7 +304,7 @@ export const NotificationProvider = ({ children }) => {
|
|||
|
||||
const show_ = (title, options) => {
|
||||
const icon = '/android-chrome-24x24.png'
|
||||
new window.Notification(title, { icon, ...options })
|
||||
window.Notification(title, { icon, ...options })
|
||||
}
|
||||
|
||||
const show = useCallback((...args) => {
|
||||
|
|
Loading…
Reference in New Issue