Skip to content

Commit

Permalink
feat: polling for guardian status, balance, and blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Kodylow committed Nov 10, 2023
1 parent 9ce8ee6 commit 39ba6cb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
10 changes: 8 additions & 2 deletions apps/guardian-ui/src/admin/FederationAdmin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,15 @@ export const FederationAdmin: React.FC = () => {

useEffect(() => {
// TODO: poll server status
api.status().then(setStatus).catch(console.error);
api.inviteCode().then(setInviteCode).catch(console.error);
api.modulesConfig().then(setModulesConfigs).catch(console.error);
api.inviteCode().then(setInviteCode).catch(console.error);
const fetchStatus = () => {
console.log('fetching status');
api.status().then(setStatus).catch(console.error);
};
fetchStatus();
const interval = setInterval(fetchStatus, 5000);
return () => clearInterval(interval);
}, [api]);

useEffect(() => {
Expand Down
7 changes: 6 additions & 1 deletion apps/guardian-ui/src/components/BalanceCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ export const BalanceCard: React.FC = () => {
: undefined;

useEffect(() => {
api.audit().then(setAuditSummary).catch(console.error);
const fetchBalance = () => {
api.audit().then(setAuditSummary).catch(console.error);
};
fetchBalance();
const interval = setInterval(fetchBalance, 5000);
return () => clearInterval(interval);
}, [api]);

const keyValues = useMemo(
Expand Down
7 changes: 6 additions & 1 deletion apps/guardian-ui/src/components/FederationInfoCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ export const FederationInfoCard: React.FC<Props> = ({ status }) => {

useEffect(() => {
api.version().then(setVersions).catch(console.error);
api.fetchBlockCount().then(setBlockCount).catch(console.error);
const fetchBlockCount = () => {
api.fetchBlockCount().then(setBlockCount).catch(console.error);
};
fetchBlockCount();
const interval = setInterval(fetchBlockCount, 5000);
return () => clearInterval(interval);
}, [api]);

const keyValues = useMemo(
Expand Down

0 comments on commit 39ba6cb

Please sign in to comment.