mail UI fixes

This commit is contained in:
Kevin Froman 2019-09-10 11:55:44 -05:00
parent f99ff27006
commit 3277192bc7
2 changed files with 62 additions and 45 deletions

View File

@ -77,40 +77,48 @@ function openReply(bHash, quote, subject){
function openThread(bHash, sender, date, sigBool, pubkey, subjectLine){ function openThread(bHash, sender, date, sigBool, pubkey, subjectLine){
addUnknownContact.style.display = 'none' addUnknownContact.style.display = 'none'
var messageDisplay = document.getElementById('threadDisplay') var messageDisplay = document.getElementById('threadDisplay')
var blockContent = httpGet('/getblockbody/' + bHash) //var blockContent = httpGet('/getblockbody/' + bHash)
document.getElementById('fromUser').value = sender || 'Anonymous' fetch('/getblockbody/' + bHash, {
document.getElementById('subjectView').innerText = subjectLine "method": "get",
messageDisplay.innerText = blockContent headers: {
var sigEl = document.getElementById('sigValid') "token": webpass
var sigMsg = 'signature' }})
.then((resp) => resp.text())
// show add unknown contact button if peer is unknown but still has pubkey .then(function(resp) {
if (sender === pubkey && sender !== myPub && sigBool){ document.getElementById('fromUser').value = sender || 'Anonymous'
addUnknownContact.style.display = 'inline' document.getElementById('subjectView').innerText = subjectLine
} messageDisplay.innerText = resp
var sigEl = document.getElementById('sigValid')
if (sigBool){ var sigMsg = 'signature'
sigMsg = 'Good ' + sigMsg
sigEl.classList.remove('danger') // show add unknown contact button if peer is unknown but still has pubkey
} if (sender === pubkey && sender !== myPub && sigBool){
else{ addUnknownContact.style.display = 'inline'
sigMsg = 'Bad/no ' + sigMsg + ' (message could be impersonating someone)'
sigEl.classList.add('danger')
replyBtn.style.display = 'none'
}
sigEl.innerText = sigMsg
overlay('messageDisplay')
replyBtn.onclick = function(){
openReply(bHash, messageDisplay.innerText, subjectLine)
}
addUnknownContact.onclick = function(){
var friendName = prompt("Enter an alias for this contact:")
if (friendName === null || friendName.length == 0){
return
} }
addContact(pubkey, friendName)
} if (sigBool){
sigMsg = 'Good ' + sigMsg
sigEl.classList.remove('danger')
}
else{
sigMsg = 'Bad/no ' + sigMsg + ' (message could be impersonating someone)'
sigEl.classList.add('danger')
replyBtn.style.display = 'none'
}
sigEl.innerText = sigMsg
overlay('messageDisplay')
replyBtn.onclick = function(){
openReply(bHash, messageDisplay.innerText, subjectLine)
}
addUnknownContact.onclick = function(){
var friendName = prompt("Enter an alias for this contact:")
if (friendName === null || friendName.length == 0){
return
}
addContact(pubkey, friendName)
}
})
} }
function setActiveTab(tabName){ function setActiveTab(tabName){
@ -139,7 +147,7 @@ function deleteMessage(bHash){
headers: { headers: {
"token": webpass "token": webpass
}}) }})
.then((resp) => resp.text()) // Transform the data into json .then((resp) => resp.text())
.then(function(resp) { .then(function(resp) {
}) })
} }
@ -185,17 +193,25 @@ function loadInboxEntries(bHash){
humanDate.setUTCSeconds(resp['meta']['time']) humanDate.setUTCSeconds(resp['meta']['time'])
humanDate = humanDate.toString() humanDate = humanDate.toString()
validSig.style.display = 'none' validSig.style.display = 'none'
if (typeof resp['meta']['signer'] != 'undefined' && resp['meta']['signer'] != ''){ if (typeof resp['meta']['signer'] != 'undefined' && resp['meta']['signer'] != ''){
let name = httpGet('/friends/getinfo/' + resp['meta']['signer'] + '/name') fetch('/friends/getinfo/' + resp['meta']['signer'] + '/name', {
if (name.length == 0){ headers: {
setHumanReadableValue(senderInput, resp['meta']['signer']) "token": webpass
entry.setAttribute('data-nameSet', false) }})
} .then(function(resp2){
else{ if (!resp2.ok){
loadHumanReadableToCache(resp['meta']['signer']) setHumanReadableValue(senderInput, resp['meta']['signer'])
senderInput.value = name entry.setAttribute('data-nameSet', false)
entry.setAttribute('data-nameSet', true) }
} else{
resp2 => resp2.text()
loadHumanReadableToCache(resp['meta']['signer'])
senderInput.value = resp2
entry.setAttribute('data-nameSet', true)
}
})
} }
else{ else{
senderInput.value = 'Anonymous' senderInput.value = 'Anonymous'
@ -347,7 +363,7 @@ fetch('/mail/getinbox', {
headers: { headers: {
"token": webpass "token": webpass
}}) }})
.then((resp) => resp.text()) // Transform the data into json .then((resp) => resp.text())
.then(function(data) { .then(function(data) {
pms = data.split(',').reverse() pms = data.split(',').reverse()
if (pms.length > 0){ if (pms.length > 0){

View File

@ -15,7 +15,8 @@ function setHumanReadableValue(el, key){
return return
} }
else{ else{
setTimeout(function(){setHumanReadableValue(el, key)}) loadHumanReadableToCache(key)
setTimeout(function(){setHumanReadableValue(el, key)}, 100)
return return
} }
} }