Skip to content

Commit

Permalink
fix(login)_: Locally cache communities outside chat loop
Browse files Browse the repository at this point in the history
  • Loading branch information
ilmotta authored May 28, 2024
1 parent d2343ee commit edc65e4
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions protocol/messenger.go
Original file line number Diff line number Diff line change
Expand Up @@ -1724,6 +1724,8 @@ func (m *Messenger) Init() error {
if err != nil {
return err
}

communityInfo := make(map[string]*communities.Community)
for _, chat := range chats {
if err := chat.Validate(); err != nil {
logger.Warn("failed to validate chat", zap.Error(err))
Expand All @@ -1740,20 +1742,13 @@ func (m *Messenger) Init() error {
continue
}

communityInfo := make(map[string]*communities.Community)

switch chat.ChatType {
case ChatTypePublic, ChatTypeProfile:
filtersToInit = append(filtersToInit, transport.FiltersToInitialize{ChatID: chat.ID})
case ChatTypeCommunityChat:
communityID, err := hexutil.Decode(chat.CommunityID)
if err != nil {
return err
}

community, ok := communityInfo[chat.CommunityID]
if !ok {
community, err = m.communitiesManager.GetByID(communityID)
community, err = m.communitiesManager.GetByIDString(chat.CommunityID)
if err != nil {
return err
}
Expand Down

0 comments on commit edc65e4

Please sign in to comment.