more new chat code in a hurry

hyperlinked-message
Thibault Duplessis 2016-06-12 10:16:14 +02:00
parent 0f82929f0d
commit d827903d67
3 changed files with 16 additions and 12 deletions

View File

@ -44,7 +44,7 @@ object Analyse extends LilaController {
(env.analyser get pov.game.id) zip
Env.fishnet.api.prioritaryAnalysisInProgress(pov.game.id) zip
(pov.game.simulId ?? Env.simul.repo.find) zip
getWatcherChat(pov.game) zip
Round.getWatcherChat(pov.game) zip
Env.game.crosstableApi(pov.game) flatMap {
case ((((analysis, analysisInProgress), simul), chat), crosstable) =>
val pgn = Env.api.pgnDump(pov.game, initialFen)
@ -71,11 +71,6 @@ object Analyse extends LilaController {
}
}
private def getWatcherChat(game: GameModel)(implicit ctx: Context) =
ctx.me ?? { me =>
Env.chat.api.userChat.findMine(s"${game.id}/w", me) map (_.some)
}
private def RedirectAtFen(pov: Pov, initialFen: Option[String])(or: => Fu[Result])(implicit ctx: Context) =
get("fen").fold(or) { atFen =>
val url = routes.Round.watcher(pov.gameId, pov.color.name)

View File

@ -139,9 +139,9 @@ object Round extends LilaController with TheftPrevention {
case Some(pov) =>
get("pov") match {
case Some(requestedPov) => (pov.player.userId, pov.opponent.userId) match {
case (Some(_),Some(opponent)) if opponent == requestedPov =>
case (Some(_), Some(opponent)) if opponent == requestedPov =>
Redirect(routes.Round.watcher(gameId, (!pov.color).name)).fuccess
case (Some(player),Some(_)) if player == requestedPov =>
case (Some(player), Some(_)) if player == requestedPov =>
Redirect(routes.Round.watcher(gameId, pov.color.name)).fuccess
case _ =>
Redirect(routes.Round.watcher(gameId, "white")).fuccess
@ -165,10 +165,11 @@ object Round extends LilaController with TheftPrevention {
else if (HTTPRequest.isHuman(ctx.req))
myTour(pov.game.tournamentId, false) zip
(pov.game.simulId ?? Env.simul.repo.find) zip
getWatcherChat(pov.game) zip
Env.game.crosstableApi(pov.game) zip
Env.api.roundApi.watcher(pov, lila.api.Mobile.Api.currentVersion, tv = none) map {
case (((tour, simul), crosstable), data) =>
Ok(html.round.watcher(pov, data, tour, simul, crosstable, userTv = userTv))
case ((((tour, simul), chat), crosstable), data) =>
Ok(html.round.watcher(pov, data, tour, simul, crosstable, userTv = userTv, myChat = chat))
}
else // web crawlers don't need the full thing
GameRepo.initialFen(pov.game.id) zip
@ -187,6 +188,11 @@ object Round extends LilaController with TheftPrevention {
Env.tournament.api.miniStanding(tid, ctx.userId, withStanding)
}
private[controllers] def getWatcherChat(game: GameModel)(implicit ctx: Context) =
ctx.me ?? { me =>
Env.chat.api.userChat.findMine(s"${game.id}/w", me) map (_.some)
}
def playerText(fullId: String) = Open { implicit ctx =>
OptionResult(GameRepo pov fullId) { pov =>
if (ctx.blindMode) Ok(html.game.textualRepresentation(pov, true))

View File

@ -1,4 +1,4 @@
@(pov: Pov, data: play.api.libs.json.JsObject, tour: Option[lila.tournament.MiniStanding], simul: Option[lila.simul.Simul], cross: Option[lila.game.Crosstable], userTv: Option[User] = None)(implicit ctx: Context)
@(pov: Pov, data: play.api.libs.json.JsObject, tour: Option[lila.tournament.MiniStanding], simul: Option[lila.simul.Simul], cross: Option[lila.game.Crosstable], userTv: Option[User] = None, myChat: Option[lila.chat.UserChat.Mine])(implicit ctx: Context)
@title = @{ s"${gameVsText(pov.game, withRatings = true)} in ${pov.gameId}" }
@ -12,6 +12,9 @@ i18n: @jsI18n()
});
});
}
@myChat.map { c =>
@chat.js(c, name = trans.spectatorRoom.str(), notes = true)
}
}
@atom = {
@ -21,7 +24,7 @@ i18n: @jsI18n()
@round.layout(
title = title,
side = views.html.game.side(pov, (data\"game"\"initialFen").asOpt[String], tour, simul = simul, userTv = userTv),
chat = ctx.isAuth.option(base.chatDom(trans.spectatorRoom.str(), ctx.isAuth)),
chat = chat.dom(myChat).some,
underchat = views.html.game.watchers().some,
moreJs = moreJs,
openGraph = povOpenGraph(pov).some,