diff --git a/app/bookmark/BookmarkApi.scala b/app/bookmark/BookmarkApi.scala index 14be7685a8..e95f9a2bfa 100644 --- a/app/bookmark/BookmarkApi.scala +++ b/app/bookmark/BookmarkApi.scala @@ -13,13 +13,13 @@ final class BookmarkApi( userRepo: UserRepo, paginator: PaginatorBuilder) { - def toggle(gameId: String, user: User): IO[Unit] = for { + def toggle(gameId: String, userId: String): IO[Unit] = for { gameOption ← gameRepo game gameId _ ← gameOption.fold( game ⇒ for { - bookmarked ← bookmarkRepo.toggle(game.id, user.id) + bookmarked ← bookmarkRepo.toggle(game.id, userId) _ ← gameRepo.incBookmarks(game.id, bookmarked.fold(1, -1)) - _ ← io(cached invalidateUserId user.id) + _ ← io(cached invalidateUserId userId) } yield (), io()) } yield () diff --git a/app/controllers/Star.scala b/app/controllers/Star.scala index 5ff669f3c1..3f432dbab8 100644 --- a/app/controllers/Star.scala +++ b/app/controllers/Star.scala @@ -12,7 +12,6 @@ object Bookmark extends LilaController { private def gameRepo = env.game.gameRepo def toggle(gameId: String) = Auth { implicit ctx ⇒ - me ⇒ - IOk(api.toggle(gameId, me)) + me ⇒ IOk(api.toggle(gameId, me.id)) } } diff --git a/app/core/CoreEnv.scala b/app/core/CoreEnv.scala index 401f4d086a..5af7cbaca9 100644 --- a/app/core/CoreEnv.scala +++ b/app/core/CoreEnv.scala @@ -117,7 +117,8 @@ final class CoreEnv private (application: Application, val settings: Settings) { lazy val importer = new lila.importer.ImporterEnv( gameRepo = game.gameRepo, hand = round.hand, - finisher = round.finisher) + finisher = round.finisher, + bookmark = bookmark.api.toggle _) lazy val tournament = new lila.tournament.TournamentEnv( app = app, diff --git a/app/importer/Importer.scala b/app/importer/Importer.scala index f55e77d10b..44d0084931 100644 --- a/app/importer/Importer.scala +++ b/app/importer/Importer.scala @@ -12,7 +12,8 @@ import akka.dispatch.Future final class Importer( gameRepo: GameRepo, hand: Hand, - finisher: Finisher) extends Futuristic { + finisher: Finisher, + bookmark: (String, String) ⇒ IO[Unit]) extends Futuristic { val delayInMs = 100 @@ -26,6 +27,9 @@ final class Importer( _ ← ((result |@| dbGame) apply { case (res, dbg) ⇒ finish(dbg, res) }) | Future() + _ ← ((dbGame |@| user) apply { + case (dbg, u) ⇒ bookmark(dbg.id, u).toFuture + }) | Future() } yield game.some case _ ⇒ Future(none) } diff --git a/app/importer/ImporterEnv.scala b/app/importer/ImporterEnv.scala index 0ab27d2c31..1caaeecee8 100644 --- a/app/importer/ImporterEnv.scala +++ b/app/importer/ImporterEnv.scala @@ -4,12 +4,15 @@ package importer import game.GameRepo import round.{ Hand, Finisher } +import scalaz.effects.IO + final class ImporterEnv( - gameRepo: GameRepo, - hand: Hand, - finisher: Finisher) { + gameRepo: GameRepo, + hand: Hand, + finisher: Finisher, + bookmark: (String, String) ⇒ IO[Unit]) { lazy val forms = new DataForm - lazy val importer = new Importer(gameRepo, hand, finisher) + lazy val importer = new Importer(gameRepo, hand, finisher, bookmark) } diff --git a/todo b/todo index 052f3b9b51..bf16e42987 100644 --- a/todo +++ b/todo @@ -58,7 +58,3 @@ recognize pgn in forum and show a pgn4web localize in chrome web store make deploy of translations easier (new project?) show language list on 2/3 columns - -deploy ------- -db.game4.ensureIndex({"me.pgni.user":1},{sparse:1})