~cytrogen/masto-fe

57a4e7927ac226a5093323484ed814ab612dd525 — Eugen Rochko 2 years ago ea8802a
[Glitch] Add client-side timeout on resend confirmation button

Port 2f932cb2bb9add10014181d978331efcf61d30f5 to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
1 files changed, 26 insertions(+), 0 deletions(-)

M app/javascript/flavours/glitch/packs/sign_up.js
M app/javascript/flavours/glitch/packs/sign_up.js => app/javascript/flavours/glitch/packs/sign_up.js +26 -0
@@ 13,4 13,30 @@ ready(() => {
      console.error(error);
    });
  }, 5000);

  document.querySelectorAll('.timer-button').forEach(button => {
    let counter = 30;

    const container = document.createElement('span');

    const updateCounter = () => {
      container.innerText = ` (${counter})`;
    };

    updateCounter();

    const countdown = setInterval(() => {
      counter--;

      if (counter === 0) {
        button.disabled = false;
        button.removeChild(container);
        clearInterval(countdown);
      } else {
        updateCounter();
      }
    }, 1000);

    button.appendChild(container);
  });
});