Fix issue whereby missing chats were messing up the zipping of the tours / simuls and chats.
This commit is contained in:
parent
a6cd6785b9
commit
a2498816fc
|
@ -35,11 +35,14 @@ object Mod extends LilaController {
|
|||
val tourChats = tourApi.fetchVisibleTournaments.flatMap {
|
||||
visibleTournaments =>
|
||||
val tournamentList = sortTournamentsByRelevance(visibleTournaments.all)
|
||||
|
||||
val ids = tournamentList.map(_.id)
|
||||
|
||||
chatApi.userChat.findAll(ids).map {
|
||||
chats =>
|
||||
tournamentList.zip(chats)
|
||||
chats.map { chat =>
|
||||
tournamentList.find(_.id === chat.id).map( tour => (tour,chat))
|
||||
}.flatten
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,7 +52,9 @@ object Mod extends LilaController {
|
|||
|
||||
chatApi.userChat.findAll(ids).map {
|
||||
chats =>
|
||||
simuls.zip(chats)
|
||||
chats.map { chat =>
|
||||
simuls.find(_.id === chat.id).map( simul => (simul,chat))
|
||||
}.flatten
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ final class ChatApi(
|
|||
findOption(chatId) map (_ | Chat.makeUser(chatId))
|
||||
|
||||
def findAll(chatIds : List[ChatId]) : Fu[List[UserChat]] =
|
||||
coll.byOrderedIds[UserChat](chatIds)(_.id)
|
||||
coll.byIds[UserChat](chatIds)
|
||||
|
||||
def findMine(chatId: ChatId, me: User): Fu[UserChat.Mine] = find(chatId) flatMap { chat =>
|
||||
(!chat.isEmpty ?? chatTimeout.isActive(chatId, me.id)) map {
|
||||
|
|
Loading…
Reference in a new issue