From 3ab892138857b1f4444e01765645072187763125 Mon Sep 17 00:00:00 2001 From: erroneousboat Date: Sat, 1 Sep 2018 18:59:00 +0200 Subject: [PATCH] Add deleted user check --- handlers/event.go | 2 -- service/slack.go | 24 ++++++++++++------------ 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/handlers/event.go b/handlers/event.go index 1f436c3..8aa4794 100644 --- a/handlers/event.go +++ b/handlers/event.go @@ -380,8 +380,6 @@ func actionSearchPrevChannels(ctx *context.AppContext) { } func actionChangeChannel(ctx *context.AppContext) { - ctx.View.Debug.Println(fmt.Sprintf("%d", ctx.View.Channels.SelectedChannel)) - // Clear messages from Chat pane ctx.View.Chat.ClearMessages() diff --git a/service/slack.go b/service/slack.go index d49030f..555ea6b 100644 --- a/service/slack.go +++ b/service/slack.go @@ -122,8 +122,8 @@ func (s *SlackService) GetChannels() []components.ChannelItem { var chans []components.ChannelItem for _, chn := range slackChans { - // Defaults + var chanName string var chanType string var presence string @@ -135,6 +135,7 @@ func (s *SlackService) GetChannels() []components.ChannelItem { } chanType = components.ChannelTypeChannel + chanName = chn.Name } if chn.IsGroup { @@ -143,31 +144,30 @@ func (s *SlackService) GetChannels() []components.ChannelItem { } chanType = components.ChannelTypeGroup + chanName = chn.Name } if chn.IsMpIM { // TODO: does it have an IsMember? // TODO: same api as im? chanType = components.ChannelTypeMpIM + chanName = chn.Name } if chn.IsIM { - // TODO: check if user is deleted. IsUsedDeleted is not present - // in the `conversation` struct. - chanType = components.ChannelTypeIM + // Check if user is deleted, we do this by checking the user id, + // and see if we have the user in the UserCache + name, ok := s.UserCache[chn.User] + if !ok { + continue + } + chanName = name + chanType = components.ChannelTypeIM // TODO: way to speed this up? see SetPresenceChannels presence, _ = s.GetUserPresence(chn.ID) } - var chanName string - name, ok := s.UserCache[chn.User] - if ok { - chanName = name - } else { - chanName = chn.Name - } - chans = append( chans, components.ChannelItem{ ID: chn.ID,