Skip to content

Commit 21027b0

Browse files
authored
Merge pull request #32 from oasisprotocol/lw/reload-5min
frontend: reload every 5 minutes (when captcha expires)
2 parents 9487f20 + d193fe1 commit 21027b0

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

faucet-frontend/src/main.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
// @ts-check
22

3+
// Reload every 5 minutes (when captcha expires)
4+
// Although this loses user inputs it is better than losing inputs and failing after submit.
5+
setTimeout(function() {
6+
window.location.reload();
7+
}, 5 * 60 * 1000);
8+
39
function $() {
410
return {
511
response_display: document.querySelector('#response_display'),
@@ -92,6 +98,18 @@ $().request_form.addEventListener('submit', (event) => {
9298

9399
preselectParatimeFromURL();
94100

101+
// Sync paratime selection back to querystring
102+
$().paratime.addEventListener('change', () => {
103+
const url = new URL(window.location.href);
104+
const selectedValue = $().paratime.value;
105+
if (selectedValue) {
106+
url.searchParams.set('paratime', selectedValue);
107+
} else {
108+
url.searchParams.delete('paratime');
109+
}
110+
window.history.replaceState({}, '', url);
111+
});
112+
95113
// Add Sapphire to MetaMask
96114
$().add_sapphire_button.addEventListener('click', () => {
97115
if (!window.ethereum?.request) {

0 commit comments

Comments
 (0)