pl-fe: migrate reports management
Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
@ -6,17 +6,11 @@ import { useAppSelector } from 'pl-fe/hooks/use-app-selector';
|
||||
import { useInstance } from 'pl-fe/hooks/use-instance';
|
||||
import { useSettings } from 'pl-fe/hooks/use-settings';
|
||||
import { usePendingUsersCount } from 'pl-fe/queries/admin/use-accounts';
|
||||
import { RootState } from 'pl-fe/store';
|
||||
import { usePendingReportsCount } from 'pl-fe/queries/admin/use-reports';
|
||||
import FaviconService from 'pl-fe/utils/favicon-service';
|
||||
|
||||
FaviconService.initFaviconService();
|
||||
|
||||
const getNotifTotals = (state: RootState): number => {
|
||||
const notifications = state.notifications.unread || 0;
|
||||
const reports = state.admin.openReports.length;
|
||||
return notifications + reports;
|
||||
};
|
||||
|
||||
interface IHelmet {
|
||||
children: React.ReactNode;
|
||||
}
|
||||
@ -25,7 +19,8 @@ const Helmet: React.FC<IHelmet> = ({ children }) => {
|
||||
const instance = useInstance();
|
||||
const { unreadChatsCount } = useStatContext();
|
||||
const { data: awaitingApprovalCount = 0 } = usePendingUsersCount();
|
||||
const unreadCount = useAppSelector((state) => getNotifTotals(state) + unreadChatsCount + awaitingApprovalCount);
|
||||
const { data: pendingReportsCount = 0 } = usePendingReportsCount();
|
||||
const unreadCount = useAppSelector((state) => state.notifications.unread || 0 + unreadChatsCount + awaitingApprovalCount + pendingReportsCount);
|
||||
const { demetricator } = useSettings();
|
||||
|
||||
const hasUnreadNotifications = React.useMemo(() => !(unreadCount < 1 || demetricator), [unreadCount, demetricator]);
|
||||
|
||||
@ -15,6 +15,7 @@ import { useOwnAccount } from 'pl-fe/hooks/use-own-account';
|
||||
import { useRegistrationStatus } from 'pl-fe/hooks/use-registration-status';
|
||||
import { useFollowRequestsCount } from 'pl-fe/queries/accounts/use-follow-requests';
|
||||
import { usePendingUsersCount } from 'pl-fe/queries/admin/use-accounts';
|
||||
import { usePendingReportsCount } from 'pl-fe/queries/admin/use-reports';
|
||||
import { scheduledStatusesCountQueryOptions } from 'pl-fe/queries/statuses/scheduled-statuses';
|
||||
import { useInteractionRequestsCount } from 'pl-fe/queries/statuses/use-interaction-requests';
|
||||
|
||||
@ -63,7 +64,8 @@ const SidebarNavigation: React.FC<ISidebarNavigation> = React.memo(({ shrink })
|
||||
const followRequestsCount = useFollowRequestsCount().data || 0;
|
||||
const interactionRequestsCount = useInteractionRequestsCount().data || 0;
|
||||
const { data: awaitingApprovalCount = 0 } = usePendingUsersCount();
|
||||
const dashboardCount = useAppSelector((state) => state.admin.openReports.length + awaitingApprovalCount);
|
||||
const { data: pendingReportsCount = 0 } = usePendingReportsCount();
|
||||
const dashboardCount = pendingReportsCount + awaitingApprovalCount;
|
||||
const scheduledStatusCount = useInfiniteQuery(authenticatedScheduledStatusesCountQueryOptions).data || 0;
|
||||
const draftCount = useAppSelector((state) => Object.keys(state.draft_statuses).length);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user