Fix issue whereby missing chats were messing up the zipping of the tours / simuls and chats.

This commit is contained in:
Gordon Martin 2016-09-04 23:16:58 +01:00
parent a6cd6785b9
commit a2498816fc
2 changed files with 8 additions and 3 deletions

View file

@ -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
}
}

View file

@ -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 {