feat: sync recent call and channel fixes
This commit is contained in:
parent
e5e0080216
commit
866a87583e
65 changed files with 6680 additions and 229 deletions
|
|
@ -87,7 +87,6 @@ func (s *ChannelStore) SearchPublicChannels(_ context.Context, viewerUserID int6
|
|||
|
||||
type item struct {
|
||||
channel domain.Channel
|
||||
joined bool
|
||||
rank int
|
||||
}
|
||||
items := make([]item, 0, limit)
|
||||
|
|
@ -98,9 +97,11 @@ func (s *ChannelStore) SearchPublicChannels(_ context.Context, viewerUserID int6
|
|||
}
|
||||
member, joined := s.members[channelID][viewerUserID]
|
||||
joined = joined && member.Status == domain.ChannelMemberActive
|
||||
if joined {
|
||||
continue
|
||||
}
|
||||
items = append(items, item{
|
||||
channel: cloneChannel(channel),
|
||||
joined: joined,
|
||||
rank: rank,
|
||||
})
|
||||
}
|
||||
|
|
@ -108,9 +109,6 @@ func (s *ChannelStore) SearchPublicChannels(_ context.Context, viewerUserID int6
|
|||
if items[i].rank != items[j].rank {
|
||||
return items[i].rank < items[j].rank
|
||||
}
|
||||
if items[i].joined != items[j].joined {
|
||||
return items[i].joined
|
||||
}
|
||||
if items[i].channel.ParticipantsCount != items[j].channel.ParticipantsCount {
|
||||
return items[i].channel.ParticipantsCount > items[j].channel.ParticipantsCount
|
||||
}
|
||||
|
|
@ -122,14 +120,10 @@ func (s *ChannelStore) SearchPublicChannels(_ context.Context, viewerUserID int6
|
|||
|
||||
out := domain.PublicChannelSearchResult{}
|
||||
for _, item := range items {
|
||||
if len(out.MyResults)+len(out.Results) >= limit {
|
||||
if len(out.Results) >= limit {
|
||||
break
|
||||
}
|
||||
if item.joined {
|
||||
out.MyResults = append(out.MyResults, item.channel)
|
||||
} else {
|
||||
out.Results = append(out.Results, item.channel)
|
||||
}
|
||||
out.Results = append(out.Results, item.channel)
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue