move to async/await

Signed-off-by: weboko <anon@mail.com>
This commit is contained in:
weboko 2022-12-09 19:42:31 +01:00 committed by weboko
parent 88aa19b06f
commit 5bee034de8
No known key found for this signature in database
1 changed files with 7 additions and 9 deletions

View File

@ -32,13 +32,12 @@ async function runApp() {
ui.onSendMessage(sendMessage); ui.onSendMessage(sendMessage);
ui.onExit(() => { ui.onExit(async () => {
ui.setStatus("disconnecting..."); ui.setStatus("disconnecting...");
unsubscribeFromMessages().then(() => { await unsubscribeFromMessages();
ui.setStatus("disconnected"); ui.setStatus("disconnected");
ui.resetMessages(); ui.resetMessages();
}); });
});
} }
async function initWakuContext({ async function initWakuContext({
@ -124,13 +123,12 @@ function initUI() {
exitButton.addEventListener("click", cb); exitButton.addEventListener("click", cb);
}, },
onSendMessage: (cb) => { onSendMessage: (cb) => {
sendButton.addEventListener("click", () => { sendButton.addEventListener("click", async () => {
cb({ await cb({
nick: nickText.value, nick: nickText.value,
text: messageText.value, text: messageText.value,
}).then(() => {
messageText.value = "";
}); });
messageText.value = "";
}); });
}, },
// UI renderers // UI renderers