Fix user presence

This commit is contained in:
erroneousboat 2018-09-02 10:14:34 +02:00
parent 3ab8921388
commit 7b2cbcfa23
3 changed files with 7 additions and 8 deletions

View File

@ -14,6 +14,7 @@ const (
IconChannel = "#"
IconGroup = "☰"
IconIM = "●"
IconMpIM = "●" // TODO
IconNotification = "*"
PresenceAway = "away"
@ -56,6 +57,8 @@ func (c ChannelItem) ToString() string {
icon = IconChannel
case ChannelTypeGroup:
icon = IconGroup
case ChannelTypeMpIM:
icon = IconMpIM
case ChannelTypeIM:
switch c.Presence {
case PresenceActive:

View File

@ -527,6 +527,7 @@ func createNotifyMessage(ctx *context.AppContext, ev *slack.MessageEvent) {
notifyTimer.Stop()
}
// Only actually notify when time expires
notifyTimer = time.NewTimer(time.Second * 2)
<-notifyTimer.C
@ -543,7 +544,6 @@ func createNotifyMessage(ctx *context.AppContext, ev *slack.MessageEvent) {
message = fmt.Sprintf("Message received from: %s", channel.Name)
}
// Only actually notify when time expires
ctx.Notify.Push("slack-term", message, "", notificator.UR_NORMAL)
}()
}

View File

@ -16,12 +16,6 @@ import (
"github.com/erroneousboat/slack-term/config"
)
const (
ChannelTypeChannel = "channel"
ChannelTypeGroup = "group"
ChannelTypeIM = "im"
)
type SlackService struct {
Config *config.Config
Client *slack.Client
@ -164,8 +158,10 @@ func (s *SlackService) GetChannels() []components.ChannelItem {
chanName = name
chanType = components.ChannelTypeIM
// TODO: way to speed this up? see SetPresenceChannels
presence, _ = s.GetUserPresence(chn.ID)
// TODO: err
presence, _ = s.GetUserPresence(chn.User)
}
chans = append(