Skip to content

Commit

Permalink
Update useDataPolling hook to show only one notification
Browse files Browse the repository at this point in the history
  • Loading branch information
OKendigelyan committed Jun 14, 2024
1 parent adc598f commit 7095276
Showing 1 changed file with 12 additions and 25 deletions.
37 changes: 12 additions & 25 deletions src/utils/dataPolling/useDataPolling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,18 @@ import { assetsActions } from "../redux/slices/assetsSlice";
export const useDataPolling = () => {
const dispatch = useAppDispatch();

const { dataUpdatedAt: isMultisigsUpdatedAt, isFetching: isMultisigsFetching } =
usePollMultisigs();
const { dataUpdatedAt: isPendingOperationsUpdatedAt, isFetching: isPendingOperationsFetching } =
usePollPendingOperations();
const { dataUpdatedAt: isTezBalancesUpdatedAt, isFetching: isTezBalancesFetching } =
usePollTezBalances();
const { dataUpdatedAt: isTokenBalancesUpdatedAt, isFetching: isTokenBalancesFetching } =
usePollTokenBalances();

usePollConversionRate();
usePollBlockLevel();
usePollBakers();

const isFetching =
isMultisigsFetching ||
isPendingOperationsFetching ||
isTezBalancesFetching ||
isTokenBalancesFetching;

const lastUpdatedAt = Math.max(
isMultisigsUpdatedAt,
isPendingOperationsUpdatedAt,
isTezBalancesUpdatedAt,
isTokenBalancesUpdatedAt
);
const pollers = [
usePollMultisigs(),
usePollPendingOperations(),
usePollTezBalances(),
usePollTokenBalances(),
usePollConversionRate(),
usePollBlockLevel(),
usePollBakers(),
];

const isFetching = pollers.some(poller => poller.isFetching);
const lastUpdatedAt = Math.max(...pollers.map(poller => poller.dataUpdatedAt));

useEffect(() => {
dispatch(assetsActions.setIsLoading(isFetching));
Expand Down

0 comments on commit 7095276

Please sign in to comment.