Newer
Older
CrypticOreWallet / src / components / wallets / SyncWallets.tsx
@Drew Lemmy Drew Lemmy on 19 Feb 2021 583 bytes feat: sync balances with websocket
import { useMountEffect } from "../../utils";

import { useDispatch, useSelector, shallowEqual } from "react-redux";
import { RootState } from "../../store";

import { syncWallets } from "../../krist/wallets/Wallet";

/** Sync the wallets with the Krist node on startup. */
export function SyncWallets(): JSX.Element | null {
  const { wallets } = useSelector((s: RootState) => s.wallets, shallowEqual);
  const dispatch = useDispatch();

  useMountEffect(() => {
    // TODO: show errors to the user?
    syncWallets(dispatch, wallets).catch(console.error);
  });

  return null;
}