mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
notifications: show toggle button on list if notifications disabled
This commit is contained in:
parent
f9e0ecdd0c
commit
14bf5be65f
8 changed files with 52 additions and 31 deletions
|
@ -38,6 +38,11 @@ export const useNotificationSettings = () => {
|
|||
update({ lastSeen: lastDate.toISOString() });
|
||||
}, [update, lastDate, lastSeen]);
|
||||
|
||||
const toggleEnabled = useCallback(
|
||||
() => update({ enabled: !settings?.enabled }),
|
||||
[update, settings],
|
||||
);
|
||||
|
||||
return {
|
||||
enabled,
|
||||
hasNew,
|
||||
|
@ -48,5 +53,6 @@ export const useNotificationSettings = () => {
|
|||
refresh,
|
||||
update,
|
||||
loading: isLoading,
|
||||
toggleEnabled,
|
||||
};
|
||||
};
|
||||
|
|
|
@ -8,13 +8,10 @@ import { useAuth } from '../auth/useAuth';
|
|||
export const useNotificationsList = () => {
|
||||
const { isUser } = useAuth();
|
||||
|
||||
const {
|
||||
data,
|
||||
isValidating: isLoading,
|
||||
error,
|
||||
} = useSWR(isUser ? API.NOTIFICATIONS.LIST : null, async () =>
|
||||
apiGetNotifications(),
|
||||
const { data, isValidating, error } = useSWR(
|
||||
isUser ? API.NOTIFICATIONS.LIST : null,
|
||||
async () => apiGetNotifications(),
|
||||
);
|
||||
|
||||
return { isLoading, error, ...data };
|
||||
return { isLoading: isValidating && !data, error, ...data };
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue