Bug fixes
This commit is contained in:
parent
9c08b9e7ea
commit
651cc73023
74
index.html
74
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) && contact in floGlobals.pubKeys) {
|
||||
if (!messenger.groups[groupID].members.includes(contact) && hasPubKey(contact)) {
|
||||
contacts.push(render.selectableContact(contact))
|
||||
}
|
||||
}
|
||||
@ -1954,7 +1954,7 @@
|
||||
// class based lazy loading
|
||||
class LazyLoader {
|
||||
constructor(container, elementsToRender, renderFn, options = {}) {
|
||||
const { batchSize = 10, freshRender, bottomFirst = false, domUpdated } = options
|
||||
const { batchSize = 10, freshRender, bottomFirst = false, onEnd } = options
|
||||
|
||||
this.elementsToRender = elementsToRender
|
||||
this.arrayOfElements = (typeof elementsToRender === 'function') ? this.elementsToRender() : elementsToRender || []
|
||||
@ -1963,8 +1963,8 @@
|
||||
|
||||
this.batchSize = batchSize
|
||||
this.freshRender = freshRender
|
||||
this.domUpdated = domUpdated
|
||||
this.bottomFirst = bottomFirst
|
||||
this.onEnd = onEnd
|
||||
|
||||
this.shouldLazyLoad = false
|
||||
this.lastScrollTop = 0
|
||||
@ -1981,6 +1981,10 @@
|
||||
return this.arrayOfElements
|
||||
}
|
||||
init() {
|
||||
if (this.mutationObserver)
|
||||
this.mutationObserver.disconnect()
|
||||
if (this.intersectionObserver)
|
||||
this.intersectionObserver.disconnect()
|
||||
this.intersectionObserver = new IntersectionObserver((entries, observer) => {
|
||||
entries.forEach(entry => {
|
||||
if (entry.isIntersecting) {
|
||||
@ -2048,8 +2052,18 @@
|
||||
this.lastScrollTop += this.lazyContainer.scrollHeight - this.lastScrollHeight
|
||||
this.lazyContainer.scrollTo({ top: this.lastScrollTop })
|
||||
this.lastScrollHeight = this.lazyContainer.scrollHeight
|
||||
if (this.updateStartIndex <= 0 && this.onEnd) {
|
||||
this.mutationObserver.disconnect()
|
||||
this.intersectionObserver.disconnect()
|
||||
this.onEnd()
|
||||
}
|
||||
} else {
|
||||
this.lazyContainer.append(frag)
|
||||
if (this.updateEndIndex >= this.arrayOfElements.length && this.onEnd) {
|
||||
this.mutationObserver.disconnect()
|
||||
this.intersectionObserver.disconnect()
|
||||
this.onEnd()
|
||||
}
|
||||
}
|
||||
if (!lazyLoad && this.bottomFirst) {
|
||||
this.lazyContainer.scrollTop = this.lazyContainer.scrollHeight
|
||||
@ -3023,6 +3037,12 @@
|
||||
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,
|
||||
@ -3032,6 +3052,8 @@
|
||||
for (let messageId in messagesData) {
|
||||
const { category, floID, time, message, sender, groupID, admin, name, pipeID, unconfirmed } = messagesData[messageId]
|
||||
const chatAddress = floID || groupID || pipeID
|
||||
const activeChatFloAdress = floCrypto.toFloID(activeChat.address)
|
||||
const activeChatBtcAddress = btcOperator.convert.legacy2bech(activeChatFloAdress)
|
||||
// code to run if a chat is opened
|
||||
if (activeChat && (activeChat.address === chatAddress || activeChat.address === floCrypto.toFloID(chatAddress))) {
|
||||
if (!sentByMe && sender && sender === floDapps.user.id) {
|
||||
@ -3044,7 +3066,7 @@
|
||||
scrollToBottom()
|
||||
}
|
||||
// remove encryption badge if it exists
|
||||
if (!groupID && floGlobals.pubKeys[activeChat.address] && floID !== floDapps.user.id) {
|
||||
if (!groupID && hasPubKey(activeChat.address) && floID !== floDapps.user.id) {
|
||||
document.getElementById('warn_no_encryption')?.remove()
|
||||
}
|
||||
}
|
||||
@ -3056,7 +3078,7 @@
|
||||
}
|
||||
// move chat card to top if it is not already there
|
||||
const topChatCard = getRef('chats_list').children[0]
|
||||
if (chatAddress !== topChatCard.dataset.floAddress || chatAddress !== floCrypto.toFloID(topChatCard.dataset.floAddress)) {
|
||||
if (chatAddress !== topChatCard.dataset.floAddress && chatAddress !== floCrypto.toFloID(topChatCard.dataset.floAddress)) {
|
||||
const cloneContact = chatCard.cloneNode(true)
|
||||
chatCard.remove()
|
||||
getRef('chats_list').animate([
|
||||
@ -3803,7 +3825,7 @@
|
||||
}
|
||||
for (const floID in floGlobals.contacts) {
|
||||
if (getFloIdType(floID) !== 'plain') continue;
|
||||
if (floGlobals.pubKeys.hasOwnProperty(floID)) {
|
||||
if (hasPubKey(floID)) {
|
||||
contacts.push(render.selectableContact(floID))
|
||||
} else {
|
||||
const hasSentRequest = skipSendingRequest.has(floID)
|
||||
@ -3885,6 +3907,18 @@
|
||||
chatLazyLoader = new LazyLoader('#messages_container', chat, render.messageBubble, {
|
||||
bottomFirst: true,
|
||||
batchSize: 20,
|
||||
onEnd: () => {
|
||||
if (activeChat.type === 'plain') {
|
||||
if (hasPubKey(activeChat.address)) {
|
||||
getRef('messages_container').prepend(html.node`<strong class="event-card flex align-center">
|
||||
<svg class="icon margin-right-0-5" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><g fill="none"><path d="M0 0h24v24H0V0z"/><path d="M0 0h24v24H0V0z" opacity=".87"/></g><path d="M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zM9 6c0-1.66 1.34-3 3-3s3 1.34 3 3v2H9V6zm9 14H6V10h12v10zm-6-3c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2z"/></svg>
|
||||
Conversation is encrypted
|
||||
</strong>`)
|
||||
} else {
|
||||
getRef('messages_container').prepend(html.node`<strong id="warn_no_encryption" class="event-card">Conversation is not encrypted until receiver replies</strong>`)
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
chatLazyLoader.init()
|
||||
@ -3902,7 +3936,7 @@
|
||||
}
|
||||
resolve()
|
||||
}).catch(error => {
|
||||
console.log(error)
|
||||
console.error(error)
|
||||
reject(error)
|
||||
})
|
||||
})
|
||||
@ -3950,12 +3984,9 @@
|
||||
getRef('chat_footer').classList.remove('hidden')
|
||||
}
|
||||
lastSender = ''
|
||||
// fix issue with encryption
|
||||
renderMessages(floID).then(async () => {
|
||||
if (activeChat.type === 'plain') {
|
||||
if (!floGlobals.pubKeys[floID]) {
|
||||
getRef('messages_container').prepend(html.node`<strong id="warn_no_encryption" class="event-card">Conversation is not encrypted until receiver replies</strong>`)
|
||||
}
|
||||
} else if (activeChat.type === 'pipeline') {
|
||||
if (activeChat.type === 'pipeline') {
|
||||
if (!messenger.pipeline[floID].disabled && floGlobals.pipeSigns[floID] && !floGlobals.pipeSigns[floID].has(floDapps.user.id)) {
|
||||
getRef('messages_container').append(html.node`
|
||||
<div class="grid gap-1 card signing-banner" style="margin: 1.5rem auto;">
|
||||
@ -4272,7 +4303,9 @@
|
||||
}
|
||||
|
||||
function getChatCard(floID) {
|
||||
return getRef('chats_list').querySelector(`[data-flo-address="${floID}"]`) || getRef('chats_list').querySelector(`[data-flo-address="${floCrypto.toFloID(floID)}"]`)
|
||||
floID = floCrypto.toFloID(floID)
|
||||
const btcID = btcOperator.convert.legacy2bech(floID)
|
||||
return getRef('chats_list').querySelector(`[data-flo-address="${floID}"], [data-flo-address="${btcID}"]`)
|
||||
}
|
||||
|
||||
function addAsContact() {
|
||||
@ -4311,7 +4344,7 @@
|
||||
getLastMessage(floGlobals.activeFloID).then(({ lastText }) => {
|
||||
chatCard.querySelector('.last-message').textContent = lastText
|
||||
}).catch(error => {
|
||||
console.log(error)
|
||||
console.error(error)
|
||||
})
|
||||
chatCard.querySelector('.last-message').textContent = 'This user is unblocked'
|
||||
notify('Address unblocked', 'success')
|
||||
@ -4354,7 +4387,7 @@
|
||||
getRef('chat_view').nextElementSibling.classList.remove('hidden')
|
||||
notify('Chat deleted', 'success')
|
||||
}).catch(error => {
|
||||
console.log(error)
|
||||
console.error(error)
|
||||
})
|
||||
}
|
||||
})
|
||||
@ -4425,7 +4458,7 @@
|
||||
render.groupMembers(groupID)
|
||||
closePopup()
|
||||
})
|
||||
.catch(err => console.log(err))
|
||||
.catch(err => console.error(err))
|
||||
}
|
||||
|
||||
function removeGroupMembers() {
|
||||
@ -4436,7 +4469,7 @@
|
||||
.then(res => {
|
||||
editGroupMembers()
|
||||
})
|
||||
.catch(err => console.log(err))
|
||||
.catch(err => console.error(err))
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -4722,8 +4755,8 @@
|
||||
})
|
||||
globalExchangeRate.btc = 1
|
||||
resolve(globalExchangeRate)
|
||||
}).catch(err => console.log(err))
|
||||
}).catch(err => console.log(err))
|
||||
}).catch(err => console.error(err))
|
||||
}).catch(err => console.error(err))
|
||||
})
|
||||
}
|
||||
function resetMultisigProcess() {
|
||||
@ -4794,7 +4827,7 @@
|
||||
return btcOperator.createSignedTx(senders, privKeys, receivers, amounts)
|
||||
}
|
||||
async function getTransactionInputs() {
|
||||
const privateKey = await floDapps.user.private.catch(err => console.log(err));
|
||||
const privateKey = await floDapps.user.private.catch(err => console.error(err));
|
||||
const privKeys = btcOperator.convert.wif(privateKey);
|
||||
const senders = floGlobals.myBtcID;
|
||||
const receivers = [...getRef('receiver_container').querySelectorAll('.receiver-input')].filter(input => input.value.trim() !== '').map(input => input.value.trim());
|
||||
@ -4886,7 +4919,6 @@
|
||||
result = await messenger.multisig.createTx_BTC(selectedMultisigAddress, redeemScript, receivers, amounts, fee)
|
||||
} else if (multisigMode === 'flo') {
|
||||
const floData = $('#send_tx__flo_data').value.trim();
|
||||
console.log(selectedMultisigAddress, receivers, amounts, floData);
|
||||
result = await messenger.multisig.createTx_FLO(floCrypto.toMultisigFloID(selectedMultisigAddress), redeemScript, receivers, amounts, floData)
|
||||
}
|
||||
console.log(result);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user