Bug fixes
This commit is contained in:
parent
9c08b9e7ea
commit
651cc73023
74
index.html
74
index.html
@ -1363,7 +1363,7 @@
|
|||||||
const contacts = []
|
const contacts = []
|
||||||
const groupID = getRef('edit_group_button').dataset.groupId;
|
const groupID = getRef('edit_group_button').dataset.groupId;
|
||||||
for (const contact in floGlobals.contacts) {
|
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))
|
contacts.push(render.selectableContact(contact))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1954,7 +1954,7 @@
|
|||||||
// class based lazy loading
|
// class based lazy loading
|
||||||
class LazyLoader {
|
class LazyLoader {
|
||||||
constructor(container, elementsToRender, renderFn, options = {}) {
|
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.elementsToRender = elementsToRender
|
||||||
this.arrayOfElements = (typeof elementsToRender === 'function') ? this.elementsToRender() : elementsToRender || []
|
this.arrayOfElements = (typeof elementsToRender === 'function') ? this.elementsToRender() : elementsToRender || []
|
||||||
@ -1963,8 +1963,8 @@
|
|||||||
|
|
||||||
this.batchSize = batchSize
|
this.batchSize = batchSize
|
||||||
this.freshRender = freshRender
|
this.freshRender = freshRender
|
||||||
this.domUpdated = domUpdated
|
|
||||||
this.bottomFirst = bottomFirst
|
this.bottomFirst = bottomFirst
|
||||||
|
this.onEnd = onEnd
|
||||||
|
|
||||||
this.shouldLazyLoad = false
|
this.shouldLazyLoad = false
|
||||||
this.lastScrollTop = 0
|
this.lastScrollTop = 0
|
||||||
@ -1981,6 +1981,10 @@
|
|||||||
return this.arrayOfElements
|
return this.arrayOfElements
|
||||||
}
|
}
|
||||||
init() {
|
init() {
|
||||||
|
if (this.mutationObserver)
|
||||||
|
this.mutationObserver.disconnect()
|
||||||
|
if (this.intersectionObserver)
|
||||||
|
this.intersectionObserver.disconnect()
|
||||||
this.intersectionObserver = new IntersectionObserver((entries, observer) => {
|
this.intersectionObserver = new IntersectionObserver((entries, observer) => {
|
||||||
entries.forEach(entry => {
|
entries.forEach(entry => {
|
||||||
if (entry.isIntersecting) {
|
if (entry.isIntersecting) {
|
||||||
@ -2048,8 +2052,18 @@
|
|||||||
this.lastScrollTop += this.lazyContainer.scrollHeight - this.lastScrollHeight
|
this.lastScrollTop += this.lazyContainer.scrollHeight - this.lastScrollHeight
|
||||||
this.lazyContainer.scrollTo({ top: this.lastScrollTop })
|
this.lazyContainer.scrollTo({ top: this.lastScrollTop })
|
||||||
this.lastScrollHeight = this.lazyContainer.scrollHeight
|
this.lastScrollHeight = this.lazyContainer.scrollHeight
|
||||||
|
if (this.updateStartIndex <= 0 && this.onEnd) {
|
||||||
|
this.mutationObserver.disconnect()
|
||||||
|
this.intersectionObserver.disconnect()
|
||||||
|
this.onEnd()
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.lazyContainer.append(frag)
|
this.lazyContainer.append(frag)
|
||||||
|
if (this.updateEndIndex >= this.arrayOfElements.length && this.onEnd) {
|
||||||
|
this.mutationObserver.disconnect()
|
||||||
|
this.intersectionObserver.disconnect()
|
||||||
|
this.onEnd()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!lazyLoad && this.bottomFirst) {
|
if (!lazyLoad && this.bottomFirst) {
|
||||||
this.lazyContainer.scrollTop = this.lazyContainer.scrollHeight
|
this.lazyContainer.scrollTop = this.lazyContainer.scrollHeight
|
||||||
@ -3023,6 +3037,12 @@
|
|||||||
updateMessageUI(data.messages)
|
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) {
|
async function updateMessageUI(messagesData, sentByMe = false) {
|
||||||
const animOptions = {
|
const animOptions = {
|
||||||
duration: 300,
|
duration: 300,
|
||||||
@ -3032,6 +3052,8 @@
|
|||||||
for (let messageId in messagesData) {
|
for (let messageId in messagesData) {
|
||||||
const { category, floID, time, message, sender, groupID, admin, name, pipeID, unconfirmed } = messagesData[messageId]
|
const { category, floID, time, message, sender, groupID, admin, name, pipeID, unconfirmed } = messagesData[messageId]
|
||||||
const chatAddress = floID || groupID || pipeID
|
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
|
// code to run if a chat is opened
|
||||||
if (activeChat && (activeChat.address === chatAddress || activeChat.address === floCrypto.toFloID(chatAddress))) {
|
if (activeChat && (activeChat.address === chatAddress || activeChat.address === floCrypto.toFloID(chatAddress))) {
|
||||||
if (!sentByMe && sender && sender === floDapps.user.id) {
|
if (!sentByMe && sender && sender === floDapps.user.id) {
|
||||||
@ -3044,7 +3066,7 @@
|
|||||||
scrollToBottom()
|
scrollToBottom()
|
||||||
}
|
}
|
||||||
// remove encryption badge if it exists
|
// 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()
|
document.getElementById('warn_no_encryption')?.remove()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3056,7 +3078,7 @@
|
|||||||
}
|
}
|
||||||
// move chat card to top if it is not already there
|
// move chat card to top if it is not already there
|
||||||
const topChatCard = getRef('chats_list').children[0]
|
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)
|
const cloneContact = chatCard.cloneNode(true)
|
||||||
chatCard.remove()
|
chatCard.remove()
|
||||||
getRef('chats_list').animate([
|
getRef('chats_list').animate([
|
||||||
@ -3803,7 +3825,7 @@
|
|||||||
}
|
}
|
||||||
for (const floID in floGlobals.contacts) {
|
for (const floID in floGlobals.contacts) {
|
||||||
if (getFloIdType(floID) !== 'plain') continue;
|
if (getFloIdType(floID) !== 'plain') continue;
|
||||||
if (floGlobals.pubKeys.hasOwnProperty(floID)) {
|
if (hasPubKey(floID)) {
|
||||||
contacts.push(render.selectableContact(floID))
|
contacts.push(render.selectableContact(floID))
|
||||||
} else {
|
} else {
|
||||||
const hasSentRequest = skipSendingRequest.has(floID)
|
const hasSentRequest = skipSendingRequest.has(floID)
|
||||||
@ -3885,6 +3907,18 @@
|
|||||||
chatLazyLoader = new LazyLoader('#messages_container', chat, render.messageBubble, {
|
chatLazyLoader = new LazyLoader('#messages_container', chat, render.messageBubble, {
|
||||||
bottomFirst: true,
|
bottomFirst: true,
|
||||||
batchSize: 20,
|
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()
|
chatLazyLoader.init()
|
||||||
@ -3902,7 +3936,7 @@
|
|||||||
}
|
}
|
||||||
resolve()
|
resolve()
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
console.log(error)
|
console.error(error)
|
||||||
reject(error)
|
reject(error)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -3950,12 +3984,9 @@
|
|||||||
getRef('chat_footer').classList.remove('hidden')
|
getRef('chat_footer').classList.remove('hidden')
|
||||||
}
|
}
|
||||||
lastSender = ''
|
lastSender = ''
|
||||||
|
// fix issue with encryption
|
||||||
renderMessages(floID).then(async () => {
|
renderMessages(floID).then(async () => {
|
||||||
if (activeChat.type === 'plain') {
|
if (activeChat.type === 'pipeline') {
|
||||||
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 (!messenger.pipeline[floID].disabled && floGlobals.pipeSigns[floID] && !floGlobals.pipeSigns[floID].has(floDapps.user.id)) {
|
if (!messenger.pipeline[floID].disabled && floGlobals.pipeSigns[floID] && !floGlobals.pipeSigns[floID].has(floDapps.user.id)) {
|
||||||
getRef('messages_container').append(html.node`
|
getRef('messages_container').append(html.node`
|
||||||
<div class="grid gap-1 card signing-banner" style="margin: 1.5rem auto;">
|
<div class="grid gap-1 card signing-banner" style="margin: 1.5rem auto;">
|
||||||
@ -4272,7 +4303,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getChatCard(floID) {
|
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() {
|
function addAsContact() {
|
||||||
@ -4311,7 +4344,7 @@
|
|||||||
getLastMessage(floGlobals.activeFloID).then(({ lastText }) => {
|
getLastMessage(floGlobals.activeFloID).then(({ lastText }) => {
|
||||||
chatCard.querySelector('.last-message').textContent = lastText
|
chatCard.querySelector('.last-message').textContent = lastText
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
console.log(error)
|
console.error(error)
|
||||||
})
|
})
|
||||||
chatCard.querySelector('.last-message').textContent = 'This user is unblocked'
|
chatCard.querySelector('.last-message').textContent = 'This user is unblocked'
|
||||||
notify('Address unblocked', 'success')
|
notify('Address unblocked', 'success')
|
||||||
@ -4354,7 +4387,7 @@
|
|||||||
getRef('chat_view').nextElementSibling.classList.remove('hidden')
|
getRef('chat_view').nextElementSibling.classList.remove('hidden')
|
||||||
notify('Chat deleted', 'success')
|
notify('Chat deleted', 'success')
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
console.log(error)
|
console.error(error)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -4425,7 +4458,7 @@
|
|||||||
render.groupMembers(groupID)
|
render.groupMembers(groupID)
|
||||||
closePopup()
|
closePopup()
|
||||||
})
|
})
|
||||||
.catch(err => console.log(err))
|
.catch(err => console.error(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeGroupMembers() {
|
function removeGroupMembers() {
|
||||||
@ -4436,7 +4469,7 @@
|
|||||||
.then(res => {
|
.then(res => {
|
||||||
editGroupMembers()
|
editGroupMembers()
|
||||||
})
|
})
|
||||||
.catch(err => console.log(err))
|
.catch(err => console.error(err))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -4722,8 +4755,8 @@
|
|||||||
})
|
})
|
||||||
globalExchangeRate.btc = 1
|
globalExchangeRate.btc = 1
|
||||||
resolve(globalExchangeRate)
|
resolve(globalExchangeRate)
|
||||||
}).catch(err => console.log(err))
|
}).catch(err => console.error(err))
|
||||||
}).catch(err => console.log(err))
|
}).catch(err => console.error(err))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
function resetMultisigProcess() {
|
function resetMultisigProcess() {
|
||||||
@ -4794,7 +4827,7 @@
|
|||||||
return btcOperator.createSignedTx(senders, privKeys, receivers, amounts)
|
return btcOperator.createSignedTx(senders, privKeys, receivers, amounts)
|
||||||
}
|
}
|
||||||
async function getTransactionInputs() {
|
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 privKeys = btcOperator.convert.wif(privateKey);
|
||||||
const senders = floGlobals.myBtcID;
|
const senders = floGlobals.myBtcID;
|
||||||
const receivers = [...getRef('receiver_container').querySelectorAll('.receiver-input')].filter(input => input.value.trim() !== '').map(input => input.value.trim());
|
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)
|
result = await messenger.multisig.createTx_BTC(selectedMultisigAddress, redeemScript, receivers, amounts, fee)
|
||||||
} else if (multisigMode === 'flo') {
|
} else if (multisigMode === 'flo') {
|
||||||
const floData = $('#send_tx__flo_data').value.trim();
|
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)
|
result = await messenger.multisig.createTx_FLO(floCrypto.toMultisigFloID(selectedMultisigAddress), redeemScript, receivers, amounts, floData)
|
||||||
}
|
}
|
||||||
console.log(result);
|
console.log(result);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user