From db8c4f6d6f6b0e29672d3bda65ff5254ce992cbb Mon Sep 17 00:00:00 2001 From: Gordon Martin Date: Sun, 4 Sep 2016 17:43:23 +0100 Subject: [PATCH] auto refresh public chat mod page WIP --- app/controllers/Mod.scala | 1 - app/views/mod/publicChat.scala.html | 12 ++++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/controllers/Mod.scala b/app/controllers/Mod.scala index 30c529cbb4..6cb221bfc3 100644 --- a/app/controllers/Mod.scala +++ b/app/controllers/Mod.scala @@ -35,7 +35,6 @@ object Mod extends LilaController { val tourChats = tourApi.fetchVisibleTournaments.flatMap { visibleTournaments => val tournamentList = sortTournamentsByRelevance(visibleTournaments.all) - val ids = tournamentList.map(_.id) chatApi.userChat.findAll(ids).map { diff --git a/app/views/mod/publicChat.scala.html b/app/views/mod/publicChat.scala.html index 45e5f469e8..7bd1714f7a 100644 --- a/app/views/mod/publicChat.scala.html +++ b/app/views/mod/publicChat.scala.html @@ -2,7 +2,19 @@ simulChats: List[(lila.simul.Simul, lila.chat.UserChat)])(implicit ctx: Context) @moreJs= { + var reloadTimer = null; + var startAutoRefresh = function () { + reloadTimer = setTimeout(function() { + $("#communication").load("@routes.Mod.publicChats" #public_communication" + }, 3000); + }; + + var stopAutoRefresh = function () { + if (reloadTimer) { + clearTimeout(reloadTimer); + } + }; } @mod.layout(