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