Keep the user consistent when browsing a crosstable.

This mostly works, however the crosstable user-order is inconsistent in
at least one place. I will investigate this further.
This commit is contained in:
Lakin Wecker 2016-05-30 08:46:45 -06:00
parent 4c196a2e5d
commit 5e5ffc656f
2 changed files with 12 additions and 3 deletions

View file

@ -137,8 +137,17 @@ object Round extends LilaController with TheftPrevention {
def watcher(gameId: String, color: String) = Open { implicit ctx =>
GameRepo.pov(gameId, color) flatMap {
case Some(pov) =>
env.checkOutoftime(pov.game)
watch(pov)
get("pov") match {
case Some(povUsername) => (pov.player.userId, pov.opponent.userId) match {
case (Some(x),Some(y)) if y == povUsername => Redirect(routes.Round.watcher(gameId, (!pov.color).name)).fuccess
case (Some(x),Some(y)) if x == povUsername => Redirect(routes.Round.watcher(gameId, pov.color.name)).fuccess
case _ => notFound
}
case None => {
env.checkOutoftime(pov.game)
watch(pov)
}
}
case None => Challenge showId gameId
}
}

View file

@ -13,7 +13,7 @@
case (r, index) => {
<td @if(currentId.??(r.gameId==)){class="current"}>
<a
href="@routes.Round.watcher(r.gameId, "white")"
href="@routes.Round.watcher(r.gameId, "white")?pov=@crosstable.user1.id"
class="glpt @r.winnerId match {
case Some(w) if w == u.id => { win }
case None => {}