resync lobby hooks on schedule

pull/41/head
Thibault Duplessis 2013-07-24 13:26:26 +02:00
parent 35507bf6d3
commit 5091b70d51
6 changed files with 25 additions and 9 deletions

View File

@ -51,6 +51,9 @@ final class Env(
scheduler.message(1 seconds) {
lobby -> lila.socket.actorApi.Broom
}
scheduler.message(10 seconds) {
socket -> actorApi.Resync
}
}
}

View File

@ -2,10 +2,9 @@ package lila.lobby
import scala.concurrent.duration._
import actorApi._
import akka.actor._
import akka.pattern.{ ask, pipe }
import actorApi._
import lila.db.api._
import lila.hub.actorApi.GetUids
import lila.memo.ExpireSetMemo
@ -18,7 +17,7 @@ private[lobby] final class Lobby(
def receive = {
case GetOpen sender ! HookRepo.allOpen
case GetOpen sender ! HookRepo.allOpen
case msg @ AddHook(hook) {
HookRepo byUid hook.uid foreach remove
@ -47,6 +46,8 @@ private[lobby] final class Lobby(
HookRepo.cleanupOld foreach remove
}
}
case Resync socket ! HookIds(HookRepo.list map (_.id))
}
private def remove(hook: Hook) = {

View File

@ -2,13 +2,9 @@ package lila.lobby
import scala.concurrent.duration._
import actorApi._
import akka.actor._
import akka.pattern.ask
import play.api.libs.iteratee._
import play.api.libs.json._
import play.api.templates.Html
import actorApi._
import lila.game.actorApi._
import lila.hub.actorApi.lobby._
import lila.hub.actorApi.router.{ Homepage, Player }
@ -16,6 +12,9 @@ import lila.hub.actorApi.timeline._
import lila.socket.actorApi.{ Connected _, _ }
import lila.socket.{ SocketActor, History, Historical }
import makeTimeout.short
import play.api.libs.iteratee._
import play.api.libs.json._
import play.api.templates.Html
private[lobby] final class Socket(
val history: History,
@ -58,9 +57,11 @@ private[lobby] final class Socket(
}
case ChangeFeatured(html) notifyFeatured(html)
case HookIds(ids) notifyVersion("hook_list", ids)
}
private def playerUrl(fullId: String) =
private def playerUrl(fullId: String) =
router ? Player(fullId) mapTo manifest[String]
private def notifyFeatured(html: Html) {

View File

@ -26,5 +26,7 @@ case class CancelHook(uid: String)
case class BiteHook(hookId: String, uid: String, userId: Option[String])
case class JoinHook(uid: String, hook: Hook, game: Game)
case class Join(uid: String, user: Option[User])
case object Resync
case class HookIds(ids: List[String])
case object GetOpen

View File

@ -2081,6 +2081,7 @@ var storage = {
},
hook_add: addHook,
hook_remove: removeHook,
hook_list: syncHookIds,
featured: changeFeatured,
redirect: function(e) {
$.lichessOpeningPreventClicks();
@ -2124,6 +2125,13 @@ var storage = {
drawHooks();
}
function syncHookIds(ids) {
pool = _.filter(pool, function(h) {
return _.contains(ids, h.id);
});
drawHooks();
}
function addHook(hook, inBatch) {
if (!isRegistered && hook.mode == "Casual" && !hook.allowAnon) return;
if (!isRegistered && hook.mode == "Rated") hook.action = 'register';

1
todo
View File

@ -57,3 +57,4 @@ customize sound notifications http://imgur.com/70WVyb5
opera issue http://en.lichess.org/forum/lichess-feedback/new-game-wont-show-on-games-list-opera#1
embedded games links http://2ls.ru/chessonline/
filter ranges http://en.lichess.org/forum/lichess-feedback/my-proposed-changes-with-filter-window#1
hooks resync (chrome does not remove them all)