From 2ff8c0f5d02ac8669c69a6eeae1df2d032f634fb Mon Sep 17 00:00:00 2001 From: sairaj mote Date: Tue, 21 Mar 2023 01:49:05 +0530 Subject: [PATCH] code refactoring --- index.html | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/index.html b/index.html index 15efda9..1f1d5ff 100644 --- a/index.html +++ b/index.html @@ -1363,7 +1363,7 @@ const contacts = [] const groupID = getRef('edit_group_button').dataset.groupId; for (const contact in floGlobals.contacts) { - if (!messenger.groups[groupID].members.includes(contact) && hasPubKey(contact)) { + if (!messenger.groups[groupID].members.includes(contact) && floDapps.user.get_pubKey(contact)) { contacts.push(render.selectableContact(contact)) } } @@ -3037,12 +3037,6 @@ updateMessageUI(data.messages) } - function hasPubKey(address) { - const floID = floCrypto.toFloID(address) - const btcAddress = btcOperator.convert.legacy2bech(floID) - return floGlobals.pubKeys.hasOwnProperty(btcAddress) || floGlobals.pubKeys.hasOwnProperty(floID) - } - async function updateMessageUI(messagesData, sentByMe = false) { const animOptions = { duration: 300, @@ -3064,7 +3058,7 @@ scrollToBottom() } // remove encryption badge if it exists - if (!groupID && hasPubKey(activeChat.address) && floID !== floDapps.user.id) { + if (!groupID && floDapps.user.get_pubKey(activeChat.address) && floID !== floDapps.user.id) { console.log('removing encryption badge') if (document.getElementById('warn_no_encryption')) { document.getElementById('warn_no_encryption').after( @@ -3492,7 +3486,7 @@ const selctedPubKeys = [...selectedMembers].map(id => { if (id === floDapps.user.id) return floDapps.user.public - return floGlobals.pubKeys[id] + return floDapps.user.get_pubKey(id) }); const minRequired = parseInt(getRef('min_sign_required').value.trim()); const label = getRef('multisig_label').value.trim(); @@ -3840,7 +3834,7 @@ } for (const floID in floGlobals.contacts) { if (getFloIdType(floID) !== 'plain') continue; - if (hasPubKey(floID)) { + if (floDapps.user.get_pubKey(floID)) { contacts.push(render.selectableContact(floID)) } else { const hasSentRequest = skipSendingRequest.has(floID) @@ -3924,7 +3918,7 @@ batchSize: 20, onEnd: () => { if (activeChat.type === 'plain') { - if (hasPubKey(activeChat.address)) { + if (floDapps.user.get_pubKey(activeChat.address)) { getRef('messages_container').prepend(html.node` Conversation is encrypted