mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
refactor: fetching notification only when popover is open (#1706)
This commit is contained in:
parent
e0affa21c4
commit
35bb71303e
@ -45,6 +45,7 @@ export const NotificationPopover = () => {
|
||||
isLoadingMore,
|
||||
hasMore,
|
||||
isRefreshing,
|
||||
setFetchNotifications,
|
||||
} = useUserNotification();
|
||||
|
||||
// theme context
|
||||
@ -66,7 +67,10 @@ export const NotificationPopover = () => {
|
||||
}}
|
||||
/>
|
||||
<Popover className="relative w-full">
|
||||
{({ open: isActive, close: closePopover }) => (
|
||||
{({ open: isActive, close: closePopover }) => {
|
||||
if (isActive) setFetchNotifications(true);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Tooltip
|
||||
tooltipContent="Notifications"
|
||||
@ -189,7 +193,8 @@ export const NotificationPopover = () => {
|
||||
</Popover.Panel>
|
||||
</Transition>
|
||||
</>
|
||||
)}
|
||||
);
|
||||
}}
|
||||
</Popover>
|
||||
</>
|
||||
);
|
||||
|
@ -25,6 +25,7 @@ const useUserNotification = () => {
|
||||
const [snoozed, setSnoozed] = useState<boolean>(false);
|
||||
const [archived, setArchived] = useState<boolean>(false);
|
||||
const [readNotification, setReadNotification] = useState<boolean>(false);
|
||||
const [fetchNotifications, setFetchNotifications] = useState<boolean>(false);
|
||||
const [selectedNotificationForSnooze, setSelectedNotificationForSnooze] = useState<string | null>(
|
||||
null
|
||||
);
|
||||
@ -49,7 +50,7 @@ const useUserNotification = () => {
|
||||
isValidating,
|
||||
mutate: notificationMutate,
|
||||
} = useSWRInfinite(
|
||||
workspaceSlug
|
||||
fetchNotifications && workspaceSlug
|
||||
? (index, prevData) =>
|
||||
getPaginatedNotificationKey(index, prevData, workspaceSlug.toString(), params)
|
||||
: () => null,
|
||||
@ -282,6 +283,7 @@ const useUserNotification = () => {
|
||||
isLoadingMore,
|
||||
hasMore,
|
||||
isRefreshing,
|
||||
setFetchNotifications,
|
||||
};
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user