mirror of
https://github.com/fazo96/telecommander.git
synced 2025-01-10 11:34:20 +01:00
few small fixes and style updates, need to check group adding from notification
This commit is contained in:
parent
2fd2e737fc
commit
d573978f7e
@ -60,8 +60,7 @@ var chats = blessed.list({
|
|||||||
invertSelected: true,
|
invertSelected: true,
|
||||||
style: defaultStyle,
|
style: defaultStyle,
|
||||||
})
|
})
|
||||||
chats.style.item = { fg: 'grey' }
|
chats.style.selected = { bold: true }
|
||||||
chats.style.selected = { fg: 'white' }
|
|
||||||
chats.focus()
|
chats.focus()
|
||||||
|
|
||||||
// Function to create a log box
|
// Function to create a log box
|
||||||
@ -365,6 +364,7 @@ function downloadData(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function addUser(u){
|
function addUser(u){
|
||||||
|
if(!user || !user.id) return log("Can't add invalid user object to contacts",u)
|
||||||
contacts[u.id] = { user: u, id: u.id}
|
contacts[u.id] = { user: u, id: u.id}
|
||||||
var name = getName(u.id,'user')
|
var name = getName(u.id,'user')
|
||||||
unameToUid[name] = u.id
|
unameToUid[name] = u.id
|
||||||
@ -374,6 +374,9 @@ function addUser(u){
|
|||||||
function addGroup(group){
|
function addGroup(group){
|
||||||
if(groups[group.id]) return;
|
if(groups[group.id]) return;
|
||||||
if(group.left === true) return;
|
if(group.left === true) return;
|
||||||
|
if(group.title === undefined){
|
||||||
|
return log('Undefined group title in group ',group)
|
||||||
|
}
|
||||||
groups[group.id] = { id: group.id, title: group.title }
|
groups[group.id] = { id: group.id, title: group.title }
|
||||||
gnameToGid[group.title] = group.id
|
gnameToGid[group.title] = group.id
|
||||||
if(!chats.getItem(group.title)) chats.addItem(group.title)
|
if(!chats.getItem(group.title)) chats.addItem(group.title)
|
||||||
@ -400,13 +403,15 @@ function downloadUpdates(){
|
|||||||
if(res.state){
|
if(res.state){
|
||||||
updateState(res.state)
|
updateState(res.state)
|
||||||
}
|
}
|
||||||
|
if(res.chats)
|
||||||
|
for(c in res.chats.list) addGroup(c)
|
||||||
|
if(res.users)
|
||||||
|
for(c in res.users.list) addUser(c)
|
||||||
if(res.new_messages){
|
if(res.new_messages){
|
||||||
res.new_messages.list.forEach(function(msg){
|
res.new_messages.list.forEach(function(msg){
|
||||||
appendMsg(msg,undefined,false,true)
|
appendMsg(msg,undefined,false,true)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if(res.chats) res.chats.list.forEach(addGroup)
|
|
||||||
if(res.users) res.users.list.forEach(addUser)
|
|
||||||
}
|
}
|
||||||
setTimeout(downloadUpdates,1000)
|
setTimeout(downloadUpdates,1000)
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user