Skip to content

Commit edc65e4

Browse files
authored
fix(login)_: Locally cache communities outside chat loop
1 parent d2343ee commit edc65e4

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

protocol/messenger.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1724,6 +1724,8 @@ func (m *Messenger) Init() error {
17241724
if err != nil {
17251725
return err
17261726
}
1727+
1728+
communityInfo := make(map[string]*communities.Community)
17271729
for _, chat := range chats {
17281730
if err := chat.Validate(); err != nil {
17291731
logger.Warn("failed to validate chat", zap.Error(err))
@@ -1740,20 +1742,13 @@ func (m *Messenger) Init() error {
17401742
continue
17411743
}
17421744

1743-
communityInfo := make(map[string]*communities.Community)
1744-
17451745
switch chat.ChatType {
17461746
case ChatTypePublic, ChatTypeProfile:
17471747
filtersToInit = append(filtersToInit, transport.FiltersToInitialize{ChatID: chat.ID})
17481748
case ChatTypeCommunityChat:
1749-
communityID, err := hexutil.Decode(chat.CommunityID)
1750-
if err != nil {
1751-
return err
1752-
}
1753-
17541749
community, ok := communityInfo[chat.CommunityID]
17551750
if !ok {
1756-
community, err = m.communitiesManager.GetByID(communityID)
1751+
community, err = m.communitiesManager.GetByIDString(chat.CommunityID)
17571752
if err != nil {
17581753
return err
17591754
}

0 commit comments

Comments
 (0)