2019-06-20 07:59:32 +00:00
|
|
|
friendList = {}
|
2019-05-18 18:46:48 +00:00
|
|
|
convoListElement = document.getElementsByClassName('conversationList')[0]
|
|
|
|
|
|
|
|
function createConvoList(){
|
2019-06-20 07:59:32 +00:00
|
|
|
console.log(friendList)
|
|
|
|
|
|
|
|
for (friend in friendList){
|
2019-07-27 07:29:16 +00:00
|
|
|
var convoEntry = document.createElement('li')
|
2019-05-18 18:46:48 +00:00
|
|
|
convoEntry.classList.add('convoEntry')
|
2019-06-20 07:59:32 +00:00
|
|
|
convoEntry.setAttribute('data-pubkey', friend)
|
|
|
|
convoEntry.innerText = friendList[friend]
|
2019-05-18 18:46:48 +00:00
|
|
|
convoListElement.append(convoEntry)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fetch('/friends/list', {
|
|
|
|
headers: {
|
|
|
|
"token": webpass
|
|
|
|
}})
|
|
|
|
.then((resp) => resp.json()) // Transform the data into json
|
|
|
|
.then(function(resp) {
|
|
|
|
var keys = []
|
|
|
|
for(var k in resp) keys.push(k)
|
|
|
|
for (var i = 0; i < keys.length; i++){
|
2019-06-20 07:59:32 +00:00
|
|
|
friendList[keys[i]] = resp[keys[i]]['name']
|
2019-05-18 18:46:48 +00:00
|
|
|
}
|
|
|
|
createConvoList()
|
2019-07-27 21:56:06 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
// Correct conversation list height
|
|
|
|
function correctConvoList(){
|
|
|
|
margin = 50
|
|
|
|
els = document.getElementsByClassName('convoListContainer')
|
|
|
|
for (x = 0; x < els.length; x++){
|
|
|
|
els[x].style.height = window.innerHeight - (2 * margin) + 'px'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
setInterval(function(){correctConvoList()}, 30)
|