From 94c27bd7f0ccf9e702b18c303074f1faeafd7135 Mon Sep 17 00:00:00 2001 From: Thibault Duplessis Date: Sat, 28 Jun 2014 12:04:24 +0200 Subject: [PATCH] use a distinct URL for pool reloading --- app/controllers/Pool.scala | 13 +++++++++---- .../pool/{refresh.scala.html => reload.scala.html} | 0 app/views/pool/show.scala.html | 3 ++- conf/routes | 1 + 4 files changed, 12 insertions(+), 5 deletions(-) rename app/views/pool/{refresh.scala.html => reload.scala.html} (100%) diff --git a/app/controllers/Pool.scala b/app/controllers/Pool.scala index 5487926408..bf860e5d3f 100644 --- a/app/controllers/Pool.scala +++ b/app/controllers/Pool.scala @@ -15,10 +15,7 @@ object Pool extends LilaController { def show(id: String) = Open { implicit ctx => OptionFuOk(env.repo byId id) { pool => - if (lila.common.HTTPRequest isXhr ctx.req) env.api.gamesOf(pool) map { games => - html.pool.refresh(pool, games) - } - else env version id zip + env version id zip chatOf(pool.setup) zip env.api.gamesOf(pool) zip pool.userCurrentPov(ctx.me).??(GameRepo.pov) map { @@ -27,6 +24,14 @@ object Pool extends LilaController { } } + def reload(id: String) = Open { implicit ctx => + OptionFuOk(env.repo byId id) { pool => + env.api.gamesOf(pool) map { games => + html.pool.reload(pool, games) + } + } + } + def help(id: String) = Open { implicit ctx => OptionOk(fuccess(env.setups get id)) { setup => html.pool.help(setup) diff --git a/app/views/pool/refresh.scala.html b/app/views/pool/reload.scala.html similarity index 100% rename from app/views/pool/refresh.scala.html rename to app/views/pool/reload.scala.html diff --git a/app/views/pool/show.scala.html b/app/views/pool/show.scala.html index e961f8f4d5..0f4632d472 100644 --- a/app/views/pool/show.scala.html +++ b/app/views/pool/show.scala.html @@ -39,7 +39,8 @@ underchat = underchat.some) {
+ data-socket-url="@routes.Pool.websocket(p.setup.id)" + data-href="@routes.Pool.reload(p.setup.id)">
@p.pairings.take(50).map { pairing => diff --git a/conf/routes b/conf/routes index d59454edd9..671ca0f66f 100644 --- a/conf/routes +++ b/conf/routes @@ -9,6 +9,7 @@ GET /timeline/more controllers.Lobby.timelineMore # Pool GET /pool/:id controllers.Pool.show(id: String) +GET /pool/:id/reload controllers.Pool.reload(id: String) GET /pool/:id/socket controllers.Pool.websocket(id: String) POST /pool/:id/enter controllers.Pool.enter(id: String) POST /pool/:id/leave controllers.Pool.leave(id: String)