mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
notifications: added profile indicator
This commit is contained in:
parent
97590d88af
commit
dc90f2505c
10 changed files with 127 additions and 37 deletions
|
@ -7,7 +7,8 @@ import { useAuth } from '../auth/useAuth';
|
|||
import { useNotificationSettingsRequest } from './useNotificationSettingsRequest';
|
||||
|
||||
export const useNotificationSettings = () => {
|
||||
const { isUser } = useAuth();
|
||||
// TODO: remove isTester
|
||||
const { isUser, isTester } = useAuth();
|
||||
|
||||
const {
|
||||
error: settingsError,
|
||||
|
@ -18,11 +19,15 @@ export const useNotificationSettings = () => {
|
|||
update,
|
||||
} = useNotificationSettingsRequest();
|
||||
|
||||
const enabled = !isLoadingSettings && !settingsError && settingsEnabled;
|
||||
const enabled =
|
||||
!isLoadingSettings && !settingsError && settingsEnabled && isTester;
|
||||
|
||||
const hasNew =
|
||||
enabled && !!lastDate && (!lastSeen || isAfter(lastDate, lastSeen));
|
||||
|
||||
// TODO: store `indicator` as option and include it here
|
||||
const indicatorEnabled = enabled && true;
|
||||
|
||||
const markAsRead = useCallback(() => {
|
||||
if (
|
||||
!lastDate ||
|
||||
|
@ -37,6 +42,7 @@ export const useNotificationSettings = () => {
|
|||
return {
|
||||
enabled,
|
||||
hasNew,
|
||||
indicatorEnabled,
|
||||
available: isUser,
|
||||
markAsRead,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue