1
0
Fork 0
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:
Fedor Katurov 2023-03-16 14:22:52 +06:00
parent f9e0ecdd0c
commit 14bf5be65f
8 changed files with 52 additions and 31 deletions

View file

@ -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,
};
};

View file

@ -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 };
};