Skip to content

Commit

Permalink
chore(ui): refresh notifications during revalidation (#3590)
Browse files Browse the repository at this point in the history
* chore(ui): refresh notifications during revalidation

* update: config
  • Loading branch information
liangfung authored and zwpaper committed Dec 19, 2024
1 parent 40e5c65 commit 779de91
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion ee/tabby-ui/components/notification-box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { HTMLAttributes, useMemo } from 'react'
import { TabsContent } from '@radix-ui/react-tabs'
import moment from 'moment'
import useSWR from 'swr'
import { useQuery } from 'urql'

import { graphql } from '@/lib/gql/generates'
Expand Down Expand Up @@ -33,10 +34,17 @@ const markNotificationsReadMutation = graphql(/* GraphQL */ `
`)

export function NotificationBox({ className, ...rest }: Props) {
const [{ data, fetching }] = useQuery({
const [{ data, fetching }, reexecuteQuery] = useQuery({
query: notificationsQuery
})

useSWR('refresh_notifications', () => reexecuteQuery(), {
revalidateOnFocus: true,
revalidateOnReconnect: true,
revalidateOnMount: false,
refreshInterval: 1000 * 60 * 10 // 10 mins
})

const notifications = useMemo(() => {
return data?.notifications.slice().reverse()
}, [data?.notifications])
Expand Down

0 comments on commit 779de91

Please sign in to comment.