mirror of
https://github.com/fazo96/telecommander.git
synced 2025-01-10 11:34:20 +01:00
fix download history bug and update readme with demo video!
This commit is contained in:
parent
f9aaa529f6
commit
93b0c8a9b6
@ -2,8 +2,12 @@
|
||||
|
||||
The experimental __full-featured curses-like command line client for Telegram__ is in heavy development, but also __already usable!__
|
||||
|
||||
![Demo](http://i.imgur.com/uv0Odoa.gif)
|
||||
|
||||
It uses [enricostara](http://github.com/enricostara)'s [telegram.link](http://github.com/enricostara/telegram.link) to connect to Telegram and [chjj](http://github.com/chjj)'s [blessed](http://github.com/chjj/blessed) for the UI.
|
||||
|
||||
In the GIF demo you can see how it looks. It was recorded with [ttystudio](http://github.com/chjj/ttystudio), which while being an excellent software, doen't really represent how good it looks with a nice font and proper color scheme. I removed most of my contacts by hacking the program to protect their privacy, but I actually have a few dozen of them and that doesn't cause issues.
|
||||
|
||||
### What it can and can't do
|
||||
|
||||
As of __now__, __Telecommander lets you__:
|
||||
|
@ -131,16 +131,18 @@ module.exports = function(data){
|
||||
},
|
||||
style: data.getDefaultStyle()
|
||||
})
|
||||
b.data.downloadedHistoryTimes = 0
|
||||
b.key('enter',function(){
|
||||
this.setScrollPerc(100)
|
||||
data.cmdline.focus()
|
||||
})
|
||||
b.on('scroll',function(){
|
||||
// The functions might not yet exist if this is the first window
|
||||
if(b.getScroll() === 100 && data.markAsRead)
|
||||
if(b.getScrollPerc() === 100 && data.markAsRead)
|
||||
data.markAsRead(data.selectedWindow)
|
||||
else if(b.getScroll() === 0 && data.getMessages)
|
||||
else if(b.getScrollPerc() === 0 && data.getMessages){
|
||||
data.getMessages(txt,b)
|
||||
}
|
||||
})
|
||||
return b
|
||||
}
|
||||
|
@ -76,6 +76,10 @@ module.exports = function(data){
|
||||
if(b.toread > 0) return 1
|
||||
return cmpstr(a,b)
|
||||
})
|
||||
list = list.filter(function(item){
|
||||
var n = data.getName(item.id,item.title?'group':'user',true)
|
||||
return n.indexOf('Michele')>=0 || n.indexOf('Telecommander')>=0 || n.indexOf('Ravinder')>=0
|
||||
})
|
||||
data.chats.setItems(list.map(function(item){
|
||||
var n = data.getName(item.id,item.title?'group':'user',true)
|
||||
if(n === undefined || n === null || !n || (n.trim && !n.trim()))
|
||||
|
@ -251,7 +251,7 @@ data.getMessages = function(name,box){
|
||||
data.downloadingMessages = true
|
||||
var oldnlines = box.getLines().length
|
||||
if(data.selectedWindow === name) data.load('Downloading history...')
|
||||
data.client.messages.getHistory(peer,0,obj.oldest_message||0,10,function(res){
|
||||
data.client.messages.getHistory(peer,0,obj.oldest_message||0,box.height,function(res){
|
||||
//log(res.toPrintable())
|
||||
//log('Got history for: '+getName(peer.user_id||peer.chat_id,peer.chat_id?'group':'user'))
|
||||
if(!res.messages){
|
||||
@ -264,8 +264,10 @@ data.getMessages = function(name,box){
|
||||
res.messages.list.forEach(function(msg){
|
||||
data.appendMsg(msg,undefined,false,true)
|
||||
})
|
||||
if(oldnlines == 0) box.setScrollPerc(100)
|
||||
if(box.data.downloadedHistoryTimes === 0) // Downloading messages for the first time
|
||||
box.setScrollPerc(100)
|
||||
//box.add(obj.oldest_message)
|
||||
box.data.downloadedHistoryTimes++
|
||||
data.loader.stop()
|
||||
data.downloadingMessages = false
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user