upgrade tournament chats
This commit is contained in:
parent
35139956e7
commit
df2d248e3c
|
@ -179,7 +179,7 @@ object Tournament extends LilaController {
|
|||
}
|
||||
|
||||
private def chatOf(tour: lila.tournament.Tournament)(implicit ctx: Context) =
|
||||
ctx.isAuth ?? {
|
||||
Env.chat.api.userChat find tour.id map (_.forUser(ctx.me).some)
|
||||
ctx.me ?? { me =>
|
||||
Env.chat.api.userChat.findMine(tour.id, me) map (_.some)
|
||||
}
|
||||
}
|
||||
|
|
5
app/views/chat/dom.scala.html
Normal file
5
app/views/chat/dom.scala.html
Normal file
|
@ -0,0 +1,5 @@
|
|||
@(c: Option[lila.chat.UserChat.Mine])(implicit ctx: Context)
|
||||
|
||||
@if(c.isDefined) {
|
||||
<div id="chat" class="side_box"></div>
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
@(sim: lila.simul.Simul, socketVersion: Int, data: play.api.libs.json.JsObject, chat: Option[lila.chat.UserChat.Mine])(implicit ctx: Context)
|
||||
@(sim: lila.simul.Simul, socketVersion: Int, data: play.api.libs.json.JsObject, myChat: Option[lila.chat.UserChat.Mine])(implicit ctx: Context)
|
||||
|
||||
@underchat = {
|
||||
<div class="watchers none" data-icon="v">
|
||||
|
@ -16,14 +16,8 @@ socketVersion: @socketVersion,
|
|||
userId: @jsUserId
|
||||
};
|
||||
}
|
||||
@chat.map { c =>
|
||||
@base.newChat(c)
|
||||
}
|
||||
}
|
||||
|
||||
@chatDom = {
|
||||
@if(chat.isDefined) {
|
||||
<div id="chat" class="side_box"></div>
|
||||
@myChat.map { c =>
|
||||
@chat.js(c)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,7 +25,7 @@ userId: @jsUserId
|
|||
title = sim.fullName,
|
||||
side = simul.side(sim).some,
|
||||
underchat = underchat.some,
|
||||
chat = chatDom.some,
|
||||
chat = chat.dom(myChat).some,
|
||||
moreJs = moreJs,
|
||||
chessground = false) {
|
||||
<div id="simul"></div>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
@(tour: Tournament, data: play.api.libs.json.JsObject, chat: Option[lila.chat.UserChat])(implicit ctx: Context)
|
||||
@(tour: Tournament, data: play.api.libs.json.JsObject, myChat: Option[lila.chat.UserChat.Mine])(implicit ctx: Context)
|
||||
|
||||
@underchat = {
|
||||
<div class="watchers none" data-icon="v">
|
||||
|
@ -16,12 +16,15 @@ i18n: @jsI18n(),
|
|||
userId: @jsUserId
|
||||
};
|
||||
}
|
||||
@myChat.map { c =>
|
||||
@chat.js(c)
|
||||
}
|
||||
}
|
||||
|
||||
@tournament.layout(
|
||||
title = s"${tour.fullName} #${tour.id}",
|
||||
side = tournament.side(tour).some,
|
||||
chat = chat.map(c => base.chat(c, trans.chatRoom.str())),
|
||||
chat = chat.dom(myChat).some,
|
||||
underchat = underchat.some,
|
||||
moreJs = moreJs,
|
||||
chessground = false,
|
||||
|
|
|
@ -22,6 +22,7 @@ private[simul] final class Socket(
|
|||
socketTimeout: Duration) extends SocketActor[Member](uidTimeout) with Historical[Member, Messadata] {
|
||||
|
||||
override def preStart() {
|
||||
super.preStart()
|
||||
lilaBus.subscribe(self, Symbol(s"chat-$simulId"))
|
||||
}
|
||||
|
||||
|
|
|
@ -33,10 +33,16 @@ private[tournament] final class Socket(
|
|||
|
||||
override def preStart() {
|
||||
super.preStart()
|
||||
lilaBus.subscribe(self, Symbol(s"chat-$tournamentId"))
|
||||
TournamentRepo byId tournamentId map SetTournament.apply pipeTo self
|
||||
}
|
||||
|
||||
def receiveSpecific = {
|
||||
override def postStop() {
|
||||
super.postStop()
|
||||
lilaBus.unsubscribe(self)
|
||||
}
|
||||
|
||||
def receiveSpecific = ({
|
||||
|
||||
case SetTournament(Some(tour)) =>
|
||||
clock = tour.clock.chessClock.some
|
||||
|
@ -70,12 +76,6 @@ private[tournament] final class Socket(
|
|||
if (timeBomb.boom) self ! PoisonPill
|
||||
}
|
||||
|
||||
case lila.chat.actorApi.ChatLine(_, line) => line match {
|
||||
case line: lila.chat.UserLine =>
|
||||
notifyVersion("message", lila.chat.JsonView(line), Messadata(line.troll))
|
||||
case _ =>
|
||||
}
|
||||
|
||||
case GetVersion => sender ! history.version
|
||||
|
||||
case Join(uid, user) =>
|
||||
|
@ -96,7 +96,9 @@ private[tournament] final class Socket(
|
|||
case NotifyReload =>
|
||||
delayedReloadNotification = false
|
||||
notifyAll("reload")
|
||||
}
|
||||
}: Actor.Receive) orElse lila.chat.Socket.out(
|
||||
send = (t, d, trollish) => notifyVersion(t, d, Messadata(trollish))
|
||||
)
|
||||
|
||||
def notifyCrowd {
|
||||
if (!delayedCrowdNotification) {
|
||||
|
|
|
@ -6,10 +6,10 @@ import akka.actor._
|
|||
import akka.pattern.ask
|
||||
|
||||
import actorApi._
|
||||
import akka.actor.ActorSelection
|
||||
import lila.common.PimpedJson._
|
||||
import lila.hub.actorApi.map._
|
||||
import lila.security.Flood
|
||||
import akka.actor.ActorSelection
|
||||
import lila.socket.actorApi.{ Connected => _, _ }
|
||||
import lila.socket.Handler
|
||||
import lila.user.User
|
||||
|
@ -42,12 +42,11 @@ private[tournament] final class SocketHandler(
|
|||
socket: ActorRef,
|
||||
tourId: String,
|
||||
uid: String,
|
||||
member: Member): Handler.Controller = {
|
||||
member: Member): Handler.Controller = ({
|
||||
case ("p", o) => o int "v" foreach { v => socket ! PingVersion(uid, v) }
|
||||
case ("talk", o) => o str "d" foreach { text =>
|
||||
member.userId foreach { userId =>
|
||||
chat ! lila.chat.actorApi.UserTalk(tourId, userId, text, socket)
|
||||
}
|
||||
}
|
||||
}
|
||||
}: Handler.Controller) orElse lila.chat.Socket.in(
|
||||
chatId = tourId,
|
||||
member = member,
|
||||
socket = socket,
|
||||
chat = chat)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue