1
0
mirror of https://github.com/fazo96/telecommander.git synced 2025-01-09 11:29:51 +01:00

added a status bar that shows last login/online status

This commit is contained in:
Enrico Fasoli 2015-09-05 15:07:53 +02:00
parent d640d6a5b6
commit 0bc343b434
4 changed files with 41 additions and 7 deletions

View File

@ -17,7 +17,7 @@ As of __now__, __Telecommander lets you__:
- Sign in with a code sent via SMS or Telegram until you delete the Telecommander session files or the session expires
- Chat in groups and in private (it also marks messages as read when you read them)
- Know when you have unread messages
- View who's online
- View who's online and when was the last time someone logged in
- Do everything __completely in the terminal, even via ssh__ using only the keyboard
- Do everything (except writing messages, duh) using only the mouse, in the terminal!
- Navigate your contact and chat list
@ -25,7 +25,6 @@ As of __now__, __Telecommander lets you__:
Waht's missing for version _0.1.0_ (__Almost done!__):
- View when was the last time someone logged in
- Download latest messages on session start and show unreads
What's missing (for future versions up to 1.0)

View File

@ -26,6 +26,7 @@ module.exports = function(data){
data.msgBox[data.selectedWindow].hide()
if(boxname === undefined){
// Leave the clear
data.statusBar.hide()
} else {
// Switch window
data.selectedWindow = boxname;
@ -37,12 +38,21 @@ module.exports = function(data){
data.cmdline.setLabel('Command for Telecommander')
}
var newb = data.getMsgBox(data.selectedWindow)
data.refreshStatusBar()
data.statusBar.show()
newb.show()
newb.emit('scroll')
}
data.screen.render()
}
data.refreshStatusBar = function(){
var obj = data.nameToObj(data.selectedWindow)
if(obj && obj.id)
data.statusBar.setContent(data.getName(obj.id,obj.title?'group':'user','statusbar'))
else data.statusBar.setContent(data.selectedWindow)
}
data.screen = blessed.screen({
smartCSR: true,
dockBorders: true
@ -117,10 +127,11 @@ module.exports = function(data){
tags: true,
mouse: true,
right: 0,
label: { text: txt, side: 'left' },
top: 2,
//label: { text: txt, side: 'left' },
width: '80%',
hidden: true,
height: data.screen.height - data.cmdline.height,
height: data.screen.height - data.cmdline.height - 2,
border: { type: 'line' },
scrollable: true,
autoscroll: true,
@ -133,9 +144,16 @@ module.exports = function(data){
},
style: data.getDefaultStyle()
})
b.on('focus',function(){
data.statusBarStyle.border.fg = b.style.focus.border.fg
data.screen.render()
})
b.on('blur',function(){
data.statusBarStyle.border.fg = b.style.border.fg
})
var obj = data.nameToObj(txt)
if(obj && obj.id)
b.setLabel(data.getName(obj.id,obj.title?'group':'user','label'))
/*if(obj && obj.id)
b.setLabel(data.getName(obj.id,obj.title?'group':'user','label'))*/
b.data.downloadedHistoryTimes = 0
b.key('enter',function(){
this.setScrollPerc(100)
@ -152,6 +170,22 @@ module.exports = function(data){
return b
}
data.statusBarStyle = data.getDefaultStyle()
data.statusBarStyle.border.fg = 'white'
data.statusBar = blessed.box({
tags: true,
input: false,
keyable: false,
keys: false,
border: { type: 'line' },
height: 3,
right: 0,
top: 0,
width: '80%',
style: data.statusBarStyle
})
data.screen.append(data.statusBar)
data.getDefaultPopupStyle = function(){
return {
width: '30%',

View File

@ -155,7 +155,7 @@ module.exports = function(data){
if(online_expires)
if(moment().isBefore(online_expires))
name = name + '{|}{green-fg}Online{/green-fg}'
else name = name + '{|}Last Seen: '+moment(online_expires).fromNow()
else name = name + '{|}Last Seen {grey-fg}'+moment(online_expires).fromNow()+'{/grey-fg}'
} else if(f === 'label'){
name = 'to ' + name
}

View File

@ -217,6 +217,7 @@ data.downloadUpdates = function(){
for(c in res.other_updates.list) data.onUpdate(res.other_updates.list[c])
}
data.rebuildChatList()
data.refreshStatusBar()
}
setTimeout(data.downloadUpdates,1000)
})