fix: make `GetChatsByChannelGroupID` return chats with members

fixes: status-im/status-desktop#10066
This commit is contained in:
Patryk Osmaczko 2023-03-30 12:56:57 +02:00 committed by osmaczko
parent 142b170ec9
commit d077c7e4bd
1 changed files with 6 additions and 8 deletions

View File

@ -389,7 +389,7 @@ func (api *API) JoinChat(ctx context.Context, communityID types.HexBytes, chatID
return api.toAPIChat(response.Chats()[0], nil, pubKey, false)
}
func (api *API) toAPIChat(protocolChat *protocol.Chat, community *communities.Community, pubKey string, onlyChat bool) (*Chat, error) {
func (api *API) toAPIChat(protocolChat *protocol.Chat, community *communities.Community, pubKey string, skipPinnedMessages bool) (*Chat, error) {
chat := &Chat{
ID: strings.TrimPrefix(protocolChat.ID, protocolChat.CommunityID),
Name: protocolChat.Name,
@ -426,7 +426,7 @@ func (api *API) toAPIChat(protocolChat *protocol.Chat, community *communities.Co
chat.Name = "" // Emptying since it contains non useful data
}
if !onlyChat {
if !skipPinnedMessages {
pinnedMessages, cursor, err := api.s.messenger.PinnedMessageByChatID(protocolChat.ID, "", -1)
if err != nil {
return nil, err
@ -445,13 +445,11 @@ func (api *API) toAPIChat(protocolChat *protocol.Chat, community *communities.Co
return nil, err
}
if !onlyChat {
chatMembers, err := getChatMembers(protocolChat, community, pubKey)
if err != nil {
return nil, err
}
chat.Members = chatMembers
chatMembers, err := getChatMembers(protocolChat, community, pubKey)
if err != nil {
return nil, err
}
chat.Members = chatMembers
return chat, nil
}