fix TV flip button

This commit is contained in:
Thibault Duplessis 2014-10-20 11:11:22 +02:00
parent 02ed27f578
commit 3b08a6f4ff
6 changed files with 13 additions and 10 deletions

View file

@ -85,12 +85,12 @@ object Round extends LilaController with TheftPrevention {
case None =>
(pov.game.tournamentId ?? TournamentRepo.byId) zip
Env.game.crosstableApi(pov.game) zip
Env.api.roundApi.watcher(pov, Env.api.version, tv = false, userTv = userTv) map {
Env.api.roundApi.watcher(pov, Env.api.version, tv = none, userTv = userTv) map {
case ((tour, crosstable), data) =>
Ok(html.round.watcher(pov, data, tour, crosstable, userTv = userTv))
}
},
api = apiVersion => Env.api.roundApi.watcher(pov, apiVersion, tv = false) map { Ok(_) }
api = apiVersion => Env.api.roundApi.watcher(pov, apiVersion, tv = none) map { Ok(_) }
)
private def join(pov: Pov)(implicit ctx: Context): Fu[Result] =

View file

@ -36,7 +36,7 @@ object Tv extends LilaController {
private def lichessTv(implicit ctx: Context) = OptionFuResult(Env.tv.featured.one) { game =>
val flip = getBool("flip")
val pov = flip.fold(Pov second game, Pov first game)
Env.api.roundApi.watcher(pov, Env.api.version, tv = true) zip
Env.api.roundApi.watcher(pov, Env.api.version, tv = flip.some) zip
(GameRepo onTv 10) zip
Env.game.crosstableApi(game) zip
Env.tv.streamsOnAir zip

View file

@ -8,4 +8,5 @@ routes.javascript.Round.watcher,
routes.javascript.Round.playerText,
routes.javascript.Round.watcherText,
routes.javascript.Round.sideWatcher,
routes.javascript.Tv.index,
routes.javascript.Tv.side)(ctx.req)

View file

@ -22,7 +22,7 @@ private[api] final class RoundApi(jsonView: JsonView) {
}
}
def watcher(pov: Pov, apiVersion: Int, tv: Boolean, userTv: Option[User] = None)(implicit ctx: Context): Fu[JsObject] =
def watcher(pov: Pov, apiVersion: Int, tv: Option[Boolean], userTv: Option[User] = None)(implicit ctx: Context): Fu[JsObject] =
jsonView.watcherJson(pov, ctx.pref, apiVersion, ctx.me, tv,
withBlurs = ctx.me ?? Granter(_.ViewBlurs)) zip
(pov.game.tournamentId ?? TournamentRepo.byId) map {

View file

@ -35,7 +35,7 @@ final class JsonView(
playerUser: Option[User],
withBlurs: Boolean): Fu[JsObject] =
getVersion(pov.game.id) zip
isGone(pov.game.id, pov.opponent.color) zip
isGone(pov.game.id, pov.opponent.color) zip
(pov.opponent.userId ?? UserRepo.byId) zip
canTakeback(pov.game) zip
getPlayerChat(pov.game, playerUser) map {
@ -121,11 +121,11 @@ final class JsonView(
pref: Pref,
apiVersion: Int,
user: Option[User],
tv: Boolean,
tv: Option[Boolean],
withBlurs: Boolean) =
getVersion(pov.game.id) zip
isGone(pov.game.id, pov.color) zip
isGone(pov.game.id, pov.opponent.color) zip
isGone(pov.game.id, pov.color) zip
isGone(pov.game.id, pov.opponent.color) zip
getWatcherChat(pov.game, user) zip
UserRepo.pair(pov.player.userId, pov.opponent.userId) map {
case ((((version, playerGone), opponentGone), chat), (playerUser, opponentUser)) =>
@ -182,7 +182,9 @@ final class JsonView(
"clockBar" -> pref.clockBar,
"showCaptured" -> pref.captured
),
"tv" -> tv,
"tv" -> tv.map { flip =>
Json.obj("flip" -> flip)
},
"chat" -> chat.map { c =>
JsArray(c.lines map {
case lila.chat.UserLine(username, text, _) => Json.obj(

View file

@ -133,7 +133,7 @@ module.exports = {
},
flip: function(ctrl) {
if (ctrl.data.player.spectator) return m('a.button[data-icon=B]', {
href: ctrl.router.Round.watcher(ctrl.data.game.id, chessground.util.opposite(ctrl.data.player.color)).url
href: ctrl.data.tv ? ctrl.router.Tv.index().url + (ctrl.data.tv.flip ? '' : '?flip=1') : ctrl.router.Round.watcher(ctrl.data.game.id, chessground.util.opposite(ctrl.data.player.color)).url
}, ctrl.trans('flipBoard'));
},
replayAndAnalyse: function(ctrl) {