remove global chat
This commit is contained in:
parent
100086ca67
commit
21de292f4f
|
@ -69,7 +69,6 @@ final class Env(
|
|||
Env.notification,
|
||||
Env.bookmark,
|
||||
Env.pref,
|
||||
Env.chat,
|
||||
Env.evaluation)
|
||||
loginfo("[boot] Preloading complete")
|
||||
}
|
||||
|
@ -120,6 +119,5 @@ object Env {
|
|||
def relation = lila.relation.Env.current
|
||||
def report = lila.report.Env.current
|
||||
def pref = lila.pref.Env.current
|
||||
def chat = lila.chat.Env.current
|
||||
def evaluation = lila.evaluation.Env.current
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ object Analyse extends LilaController {
|
|||
Redirect(routes.Analyse.replay(id, color)).fuccess
|
||||
}
|
||||
|
||||
def replay(id: String, color: String) = OpenWithChan(lila.chat.GameWatcherChan(id)) { implicit ctx ⇒
|
||||
def replay(id: String, color: String) = Open { implicit ctx ⇒
|
||||
OptionFuOk(GameRepo.pov(id, color)) { pov ⇒
|
||||
Env.round.version(pov.gameId) zip
|
||||
(bookmarkApi userIdsByGame pov.game) zip
|
||||
|
@ -52,7 +52,7 @@ object Analyse extends LilaController {
|
|||
}
|
||||
}
|
||||
|
||||
def stats(id: String) = OpenWithChan(lila.chat.GameWatcherChan(id)) { implicit ctx ⇒
|
||||
def stats(id: String) = Open { implicit ctx ⇒
|
||||
OptionFuOk(GameRepo game id) { game ⇒
|
||||
timeChart(game) map { chart ⇒
|
||||
html.analyse.stats(
|
||||
|
|
|
@ -12,7 +12,6 @@ import scalaz.Monoid
|
|||
|
||||
import lila.api.{ PageData, Context, HeaderContext, BodyContext }
|
||||
import lila.app._
|
||||
import lila.chat.{ Chat, Chan }
|
||||
import lila.common.{ LilaCookie, HTTPRequest }
|
||||
import lila.security.{ Permission, Granter }
|
||||
import lila.user.{ User ⇒ UserModel }
|
||||
|
@ -49,9 +48,6 @@ private[controllers] trait LilaController
|
|||
protected def Open[A](p: BodyParser[A])(f: Context ⇒ Fu[SimpleResult]): Action[A] =
|
||||
Action.async(p)(req ⇒ reqToCtx(req) flatMap f)
|
||||
|
||||
protected def OpenWithChan(chan: lila.chat.Chan)(f: Context ⇒ Fu[SimpleResult]): Action[AnyContent] =
|
||||
Action.async(BodyParsers.parse.anyContent)(req ⇒ reqToCtx(req, chan.some) flatMap f)
|
||||
|
||||
protected def OpenBody(f: BodyContext ⇒ Fu[SimpleResult]): Action[AnyContent] =
|
||||
OpenBody(BodyParsers.parse.anyContent)(f)
|
||||
|
||||
|
@ -172,9 +168,9 @@ private[controllers] trait LilaController
|
|||
protected def authorizationFailed(req: RequestHeader): SimpleResult =
|
||||
Forbidden("no permission")
|
||||
|
||||
protected def reqToCtx(req: RequestHeader, withChan: Option[Chan] = None): Fu[HeaderContext] =
|
||||
protected def reqToCtx(req: RequestHeader): Fu[HeaderContext] =
|
||||
restoreUser(req) map { lila.user.UserContext(req, _) } flatMap { ctx ⇒
|
||||
pageDataBuilder(ctx, withChan) map { Context(ctx, _) }
|
||||
pageDataBuilder(ctx) map { Context(ctx, _) }
|
||||
}
|
||||
|
||||
protected def reqToCtx(req: Request[_]): Fu[BodyContext] =
|
||||
|
@ -182,22 +178,10 @@ private[controllers] trait LilaController
|
|||
pageDataBuilder(ctx) map { Context(ctx, _) }
|
||||
}
|
||||
|
||||
private def pageDataBuilder(ctx: lila.user.UserContext, withChan: Option[Chan] = None): Fu[PageData] =
|
||||
private def pageDataBuilder(ctx: lila.user.UserContext): Fu[PageData] =
|
||||
ctx.me.fold(fuccess(PageData.default)) { me ⇒
|
||||
val isPage = HTTPRequest.isSynchronousHttp(ctx.req)
|
||||
(isPage ?? {
|
||||
Env.chat.api get me flatMap { chat ⇒
|
||||
val pageChat = withChan.fold(chat) { chan ⇒
|
||||
Env.chat.api.truncate(me, chat withPageChan chan, chan.key)
|
||||
}
|
||||
Env.chat.api.populate(pageChat, me)
|
||||
} map (_.some)
|
||||
} recover {
|
||||
case e: Exception ⇒ {
|
||||
play.api.Logger("controller").warn(e.getMessage)
|
||||
none
|
||||
}
|
||||
}) zip (Env.pref.api getPref me) zip {
|
||||
(Env.pref.api getPref me) zip {
|
||||
isPage ?? {
|
||||
import lila.hub.actorApi.relation._
|
||||
import akka.pattern.ask
|
||||
|
@ -211,7 +195,7 @@ private[controllers] trait LilaController
|
|||
JsArray(teams map { t ⇒ Json.obj("id" -> t.id, "name" -> t.name) }).some
|
||||
}
|
||||
} map {
|
||||
case (((chat, pref), friends), teams) ⇒ PageData(chat, friends, pref, teams)
|
||||
case ((pref, friends), teams) ⇒ PageData(friends, pref, teams)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,37 +38,30 @@ object Round extends LilaController with TheftPrevention {
|
|||
JsOk(fuccess(Env.game.gameJs.sign(env.hijack tokenOf gameId)), CACHE_CONTROL -> "max-age=3600")
|
||||
}
|
||||
|
||||
def player(fullId: String) = Action async { req ⇒
|
||||
GameRepo pov fullId flatMap {
|
||||
case None ⇒ notFoundReq(req)
|
||||
case Some(pov) ⇒ (OpenWithChan(pov.game.hasAi.fold(
|
||||
lila.chat.GameWatcherChan(pov.gameId),
|
||||
lila.chat.GamePlayerChan(pov.gameId)
|
||||
)) { implicit ctx ⇒
|
||||
if (pov.game.playableByAi) env.roundMap ! Tell(pov.game.id, AiPlay)
|
||||
pov.game.started.fold(
|
||||
PreventTheft(pov) {
|
||||
env.version(pov.gameId) zip
|
||||
(bookmarkApi userIdsByGame pov.game) zip
|
||||
pov.opponent.userId.??(UserRepo.isEngine) zip
|
||||
(analyser has pov.gameId) zip
|
||||
(pov.game.tournamentId ?? TournamentRepo.byId) map {
|
||||
case ((((v, bookmarkers), engine), analysed), tour) ⇒
|
||||
Ok(html.round.player(pov, v, engine, bookmarkers, analysed, tour = tour))
|
||||
}
|
||||
},
|
||||
Redirect(routes.Setup.await(fullId)).fuccess
|
||||
)
|
||||
})(req)
|
||||
def player(fullId: String) = Open { implicit ctx ⇒
|
||||
OptionFuResult(GameRepo pov fullId) { pov ⇒
|
||||
if (pov.game.playableByAi) env.roundMap ! Tell(pov.game.id, AiPlay)
|
||||
pov.game.started.fold(
|
||||
PreventTheft(pov) {
|
||||
env.version(pov.gameId) zip
|
||||
(bookmarkApi userIdsByGame pov.game) zip
|
||||
pov.opponent.userId.??(UserRepo.isEngine) zip
|
||||
(analyser has pov.gameId) zip
|
||||
(pov.game.tournamentId ?? TournamentRepo.byId) map {
|
||||
case ((((v, bookmarkers), engine), analysed), tour) ⇒
|
||||
Ok(html.round.player(pov, v, engine, bookmarkers, analysed, tour = tour))
|
||||
}
|
||||
},
|
||||
Redirect(routes.Setup.await(fullId)).fuccess
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
def watcher(gameId: String, color: String) =
|
||||
OpenWithChan(lila.chat.GameWatcherChan(gameId)) { implicit ctx ⇒
|
||||
OptionFuResult(GameRepo.pov(gameId, color)) { pov ⇒
|
||||
pov.game.joinable.fold(join _, watch _)(pov)
|
||||
}
|
||||
def watcher(gameId: String, color: String) = Open { implicit ctx ⇒
|
||||
OptionFuResult(GameRepo.pov(gameId, color)) { pov ⇒
|
||||
pov.game.joinable.fold(join _, watch _)(pov)
|
||||
}
|
||||
}
|
||||
|
||||
private def watch(pov: Pov)(implicit ctx: Context): Fu[SimpleResult] =
|
||||
bookmarkApi userIdsByGame pov.game zip
|
||||
|
|
|
@ -42,7 +42,7 @@ object Tournament extends LilaController {
|
|||
private def tournaments =
|
||||
repo.created zip repo.started zip repo.finished(20)
|
||||
|
||||
def show(id: String) = OpenWithChan(lila.chat.TournamentChan(id)) { implicit ctx ⇒
|
||||
def show(id: String) = Open { implicit ctx ⇒
|
||||
repo byId id flatMap {
|
||||
_ match {
|
||||
case Some(tour: Created) ⇒ showCreated(tour) map { Ok(_) }
|
||||
|
|
|
@ -11,7 +11,7 @@ import views._
|
|||
|
||||
object Tv extends LilaController {
|
||||
|
||||
def index = OpenWithChan(lila.chat.TvChan) { implicit ctx ⇒
|
||||
def index = Open { implicit ctx ⇒
|
||||
OptionFuResult(Env.game.featured.one) { game ⇒
|
||||
Env.round.version(game.id) zip
|
||||
(GameRepo onTv 10) zip
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
package lila.app
|
||||
package templating
|
||||
|
||||
import lila.chat.Env.{ current ⇒ chatEnv }
|
||||
import lila.user.User
|
||||
|
||||
trait ChatHelper {
|
||||
|
||||
def chatNameChans(chans: List[lila.chat.Chan], as: User): List[lila.chat.NamedChan] = chans match {
|
||||
case Nil ⇒ Nil
|
||||
case cs ⇒ chatEnv.namer.chans(cs, as).await
|
||||
}
|
||||
}
|
|
@ -40,8 +40,7 @@ object Environment
|
|||
with TeamHelper
|
||||
with AnalysisHelper
|
||||
with RelationHelper
|
||||
with TournamentHelper
|
||||
with ChatHelper {
|
||||
with TournamentHelper {
|
||||
|
||||
implicit val LilaHtmlMonoid = scalaz.Monoid.instance[Html](
|
||||
(a, b) ⇒ Html(a.body + b.body),
|
||||
|
|
|
@ -151,59 +151,9 @@ data-accept-languages="@acceptLanguages.mkString(",")">
|
|||
Ping: <span id="connection_lag">?</span>
|
||||
</div>
|
||||
</div>
|
||||
@ctx.me.map { me =>
|
||||
@ctx.chat.map { c =>
|
||||
<div id="chat_wrap"@if(ctx.pref.chat.on) { class="on"}>
|
||||
<div class="bar">
|
||||
<div class="left"><a class="on">@trans.chat()</a></div>
|
||||
<div class="right friends">
|
||||
@trans.onlineFriends() - <strong class="online"> </strong>/<span class="total"> </span>
|
||||
</div>
|
||||
<div class="center last"></div>
|
||||
</div>
|
||||
<div id="chat" style="height:@{ctx.pref.chat.height}px">
|
||||
<a class="off"></a>
|
||||
<a class="help">help</a>
|
||||
<div class="left chans"></div>
|
||||
<div class="right lists">
|
||||
<div class="tabs">
|
||||
<a data-tab="friends" class="friends">@trans.onlineFriends()</a>
|
||||
<a data-tab="teams" class="teams">@trans.teams()</a>
|
||||
</div>
|
||||
<div id="team_box" class="list_box teams" data-preload="@ctx.teams">
|
||||
<div class="content"></div>
|
||||
</div>
|
||||
<div id="friend_box" class="list_box friends" data-preload="@ctx.friends">
|
||||
<div class="content"></div>
|
||||
<div class="nobody">
|
||||
<span>@trans.noFriendsOnline()</span>
|
||||
<a class="find button" href="@routes.Relation.suggest(me.username)">
|
||||
<span class="s16 tup">@trans.findFriends()</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="center room">
|
||||
<div class="lines" style="height:@{ctx.pref.chat.height - 28}px"></div>
|
||||
<div class="controls">
|
||||
<form action="#">
|
||||
<input class="input" value="" placeholder="@trans.talkInChat()" />
|
||||
<span class="invite"></span>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
}
|
||||
@jsTag("deps.min.js")
|
||||
@signedJs.fold(jsTagCompiled("big.js"))(js => jsAt(js, false))
|
||||
@ctx.me.map { u =>
|
||||
@ctx.chat.map { c =>
|
||||
@embedJs("var _lc_ = " + toJson(c.toJson))
|
||||
}
|
||||
}
|
||||
@moreJs
|
||||
@if(lang.language != "en") {
|
||||
@jsAt(s"trans/${lang.language}.js")
|
||||
|
|
|
@ -3,18 +3,16 @@ package lila.api
|
|||
import play.api.libs.json.{ JsObject, JsArray }
|
||||
import play.api.mvc.{ Request, RequestHeader }
|
||||
|
||||
import lila.chat.Chat
|
||||
import lila.pref.Pref
|
||||
import lila.user.{ UserContext, HeaderUserContext, BodyUserContext }
|
||||
|
||||
case class PageData(
|
||||
chat: Option[Chat],
|
||||
friends: Option[JsObject],
|
||||
pref: Pref,
|
||||
teams: Option[JsArray])
|
||||
|
||||
object PageData {
|
||||
val default = PageData(none, none, Pref.default, none)
|
||||
val default = PageData(none, Pref.default, none)
|
||||
}
|
||||
|
||||
sealed trait Context extends lila.user.UserContextWrapper {
|
||||
|
@ -22,7 +20,6 @@ sealed trait Context extends lila.user.UserContextWrapper {
|
|||
val userContext: UserContext
|
||||
val pageData: PageData
|
||||
|
||||
def chat = pageData.chat
|
||||
def friends = pageData.friends
|
||||
def pref = pageData.pref
|
||||
def teams = pageData.teams
|
||||
|
|
|
@ -31,7 +31,7 @@ object ApplicationBuild extends Build {
|
|||
gameSearch, timeline, forum, forumSearch, team, teamSearch,
|
||||
ai, analyse, mod, monitor, site, round, lobby, setup,
|
||||
importer, tournament, relation, report, pref, simulation,
|
||||
chat, evaluation)
|
||||
evaluation)
|
||||
|
||||
lazy val moduleRefs = modules map projectToRef
|
||||
lazy val moduleCPDeps = moduleRefs map { new sbt.ClasspathDependency(_, None) }
|
||||
|
|
1
todo
1
todo
|
@ -116,3 +116,4 @@ graph on the user page is ~3px to the left of where it should be
|
|||
give AI levels ratings
|
||||
chess960 castling bug http://en.lichess.org/analyse/ligpcaoi
|
||||
http://en.lichess.org/@/JoSopinka in top slow with only 4 slow games (should index more perf deviations)
|
||||
lichess unmarks! http://en.lichess.org/mod/log
|
||||
|
|
Loading…
Reference in a new issue