show if homeserver URL is invalid

This commit is contained in:
b1ek 2023-08-26 11:26:02 +10:00
parent caf5bf154e
commit 59af88a7c7
Signed by: blek
GPG Key ID: 14546221E3595D0C
1 changed files with 14 additions and 1 deletions

View File

@ -4,6 +4,13 @@
import AccountStore from '../../store/AccountStore'; import AccountStore from '../../store/AccountStore';
let homeserver = AccountStore.getState().homeserver; let homeserver = AccountStore.getState().homeserver;
let homeserverValid = homeserver.match(/.+(\..+){1,}/gm) !== null;
const updStore = () => {
AccountStore.dispatch({ type: 'setHomeserver', homeserver });
console.log(AccountStore.getState().homeserver);
homeserverValid = homeserver.match(/.+(\..+){1,}/gm) !== null;
}
</script> </script>
<div class={style.root}> <div class={style.root}>
@ -11,7 +18,7 @@
<p style="text-align:center"> <p style="text-align:center">
To continue, you must choose a homeserver<br/> To continue, you must choose a homeserver<br/>
<input type='text' value={homeserver} style="background: #ffeeee06"> <input type='text' bind:value={homeserver} on:input={updStore} style="background: #ffeeee06">
<br/> <br/>
<button>What is a homeserver?</button> <button>What is a homeserver?</button>
@ -19,5 +26,11 @@
</p> </p>
<p style="text-align:center"> <p style="text-align:center">
<button class="primary">Choose {homeserver}</button> <button class="primary">Choose {homeserver}</button>
{#if (!homeserverValid)}
<br/>
<span style='font-size:10pt;color:darkred'>
Error: Invalid URL
</span>
{/if}
</p> </p>
</div> </div>