feat: remove set nick button, ensure send button is enabled once subscribed

This commit is contained in:
fryorcraken.eth 2022-10-06 11:11:43 +11:00
parent e7e61c67b8
commit e24cdb0540
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
1 changed files with 4 additions and 11 deletions

View File

@ -53,7 +53,6 @@
<br/> <br/>
<label for='nick-input'>Your nickname</label> <label for='nick-input'>Your nickname</label>
<input id='nick-input' placeholder='Choose a nickname' type='text'> <input id='nick-input' placeholder='Choose a nickname' type='text'>
<button disabled id='set-nick' type='button'>Set nickname</button>
<br/> <br/>
<label for='textInput'>Message text</label> <label for='textInput'>Message text</label>
@ -115,7 +114,6 @@
const dialButton = document.getElementById('dial') const dialButton = document.getElementById('dial')
const nicknameInput = document.getElementById('nick-input') const nicknameInput = document.getElementById('nick-input')
const setNickButton = document.getElementById('set-nick')
const textInput = document.getElementById('textInput'); const textInput = document.getElementById('textInput');
const sendButton = document.getElementById('sendButton'); const sendButton = document.getElementById('sendButton');
@ -123,7 +121,7 @@
const messagesDiv = document.getElementById('messages') const messagesDiv = document.getElementById('messages')
let membershipId, membershipKey, encoder, node, nodeConnected, nick, rlnInstance; let membershipId, membershipKey, encoder, node, nodeConnected, rlnInstance;
let retrievedRLNEvents = false; let retrievedRLNEvents = false;
const rlnInstancePromise = create(); const rlnInstancePromise = create();
@ -172,12 +170,10 @@
&& identityKeyInput.value && identityKeyInput.value
&& commitmentKeyInput.value); && commitmentKeyInput.value);
const readyToSend = (membershipKey && membershipId && nodeConnected && nick) const readyToSend = (membershipKey && membershipId && nodeConnected && nicknameInput.value)
textInput.disabled = !readyToSend; textInput.disabled = !readyToSend;
sendButton.disabled = !readyToSend; sendButton.disabled = !readyToSend;
setNickButton.disabled = !nicknameInput.value;
dialButton.disabled = !(node && node.isStarted() && retrievedRLNEvents) dialButton.disabled = !(node && node.isStarted() && retrievedRLNEvents)
retrieveRLNDetailsButton.disabled = !rlnInstance && !retrievedRLNEvents; retrieveRLNDetailsButton.disabled = !rlnInstance && !retrievedRLNEvents;
@ -311,10 +307,6 @@
// Waku // Waku
nicknameInput.onchange = updateFields nicknameInput.onchange = updateFields
setNickButton.onclick = () => {
nick = nicknameInput.value;
updateFields()
}
let messages = []; let messages = [];
@ -397,12 +389,13 @@
await node.filter.subscribe([decoder], callback) await node.filter.subscribe([decoder], callback)
statusDiv.innerHTML = '<p>Waku node subscribed.</p>'; statusDiv.innerHTML = '<p>Waku node subscribed.</p>';
nodeConnected = true; nodeConnected = true;
updateFields()
} }
sendButton.onclick = async () => { sendButton.onclick = async () => {
const text = utils.utf8ToBytes(textInput.value); const text = utils.utf8ToBytes(textInput.value);
const timestamp = new Date(); const timestamp = new Date();
const msg = ProtoChatMessage.create({text, nick, timestamp: timestamp.valueOf()}); const msg = ProtoChatMessage.create({text, nick: nicknameInput.value, timestamp: timestamp.valueOf()});
const payload = ProtoChatMessage.encode(msg).finish(); const payload = ProtoChatMessage.encode(msg).finish();
console.log("Sending message with proof...") console.log("Sending message with proof...")
sendingStatusSpan.innerText = 'sending...' sendingStatusSpan.innerText = 'sending...'