preload chats
This commit is contained in:
parent
45212b0823
commit
ab08042f21
|
@ -20,6 +20,18 @@ func (m *Messenger) Chats() []*Chat {
|
|||
return chats
|
||||
}
|
||||
|
||||
func (m *Messenger) LatestActiveNChats(num int) []*Chat {
|
||||
var chats []*Chat
|
||||
var i = 0
|
||||
m.allChats.Range(func(chatID string, chat *Chat) (shouldContinue bool) {
|
||||
chats = append(chats, chat)
|
||||
i++
|
||||
return i < num
|
||||
})
|
||||
|
||||
return chats
|
||||
}
|
||||
|
||||
func (m *Messenger) ActiveChats() []*Chat {
|
||||
m.mutex.Lock()
|
||||
defer m.mutex.Unlock()
|
||||
|
|
|
@ -267,6 +267,10 @@ func (api *PublicAPI) Chats(parent context.Context) []*protocol.Chat {
|
|||
return api.service.messenger.Chats()
|
||||
}
|
||||
|
||||
func (api *PublicAPI) LatestActiveNChats(parent context.Context, num int) []*protocol.Chat {
|
||||
return api.service.messenger.LatestActiveNChats(num)
|
||||
}
|
||||
|
||||
func (api *PublicAPI) ActiveChats(parent context.Context) []*protocol.Chat {
|
||||
return api.service.messenger.ActiveChats()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue