-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 🎸 Added "completed" status check to the migration page
Not it is possible to get to the "resolver" page from the migration page for copleted DIDs
- Loading branch information
Showing
6 changed files
with
98 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { useEffect } from 'react'; | ||
|
||
export type PollerContextFunction = () => void | Promise<void>; | ||
|
||
export const usePoller = ( | ||
fn: PollerContextFunction, | ||
enabled = true, | ||
interval = 5000, | ||
pollerName?: string, | ||
) => { | ||
if (typeof fn !== 'function') { | ||
throw new TypeError("Can't poll without a callback function"); | ||
} | ||
|
||
return useEffect(() => { | ||
let disabled = false; | ||
let failures = 0; | ||
|
||
const poll = async () => { | ||
if (disabled || !enabled) { | ||
return; | ||
} | ||
|
||
try { | ||
await fn(); | ||
} catch (error) { | ||
failures++; | ||
} | ||
|
||
if (failures < 100) { | ||
setTimeout(poll, interval); | ||
} | ||
}; | ||
|
||
if (enabled) { | ||
poll(); | ||
} | ||
|
||
return () => { | ||
disabled = true; | ||
failures = 0; | ||
}; | ||
}, [fn, enabled, interval, pollerName]); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters