diff --git a/README.md b/README.md index 1248a05..1523d7f 100644 --- a/README.md +++ b/README.md @@ -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__: diff --git a/lib/ui.js b/lib/ui.js index cda1b6d..9b5f83a 100644 --- a/lib/ui.js +++ b/lib/ui.js @@ -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 } diff --git a/lib/util.js b/lib/util.js index 2cb4085..bad9925 100644 --- a/lib/util.js +++ b/lib/util.js @@ -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())) diff --git a/telecommander.js b/telecommander.js index 10b4179..68bb766 100755 --- a/telecommander.js +++ b/telecommander.js @@ -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 })