permanent TV chat
This commit is contained in:
parent
eb2ad2c832
commit
7705b8dd95
|
@ -14,7 +14,7 @@ object Tv extends LilaController {
|
|||
def index = Open { implicit ctx ⇒
|
||||
OptionFuResult(Env.game.featured.one) { game ⇒
|
||||
Env.round.version(game.id) zip
|
||||
(WatcherRoomRepo room game.id map { room ⇒
|
||||
(WatcherRoomRepo room "tv" map { room ⇒
|
||||
html.round.watcherRoomInner(room.decodedMessages)
|
||||
}) zip
|
||||
(GameRepo onTv 10) zip
|
||||
|
|
|
@ -8,10 +8,16 @@
|
|||
</div>
|
||||
}
|
||||
|
||||
@room = {
|
||||
@base.chatRoom(
|
||||
title = "TV " + trans.spectatorRoom.str(),
|
||||
cssClass = "spectators")(roomHtml)
|
||||
}
|
||||
|
||||
@round.layout(
|
||||
title = title,
|
||||
goodies = views.html.game.infoBox(pov, tour),
|
||||
chat = round.room(roomHtml, true).some,
|
||||
chat = room.some,
|
||||
underchat = underchat.some,
|
||||
active = siteMenu.tv.some) {
|
||||
@round.watcherGame(pov)
|
||||
|
|
|
@ -52,14 +52,14 @@ final class Messenger(
|
|||
}
|
||||
|
||||
def watcherMessage(
|
||||
gameId: String,
|
||||
roomId: String,
|
||||
userId: Option[String],
|
||||
text: String,
|
||||
troll: Boolean): Fu[List[Event.WatcherMessage]] = for {
|
||||
userOption ← userId.??(UserRepo.byId)
|
||||
message ← userOrAnonMessage(userOption, text).future
|
||||
(u, t) = message
|
||||
_ ← !troll ?? WatcherRoomRepo.addMessage(gameId, u, t)
|
||||
_ ← !troll ?? WatcherRoomRepo.addMessage(roomId, u, t)
|
||||
} yield Event.WatcherMessage(u, t, troll) :: Nil
|
||||
|
||||
def systemMessages(game: Game, messages: List[SelectI18nKey]): Fu[List[Event]] =
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package lila.round
|
||||
|
||||
import actorApi._, round._
|
||||
import akka.actor._
|
||||
import akka.pattern.{ ask, pipe }
|
||||
import chess.Color
|
||||
import makeTimeout.short
|
||||
import play.api.libs.json.{ JsObject, Json }
|
||||
|
||||
import actorApi._, round._
|
||||
import chess.Color
|
||||
import lila.common.PimpedJson._
|
||||
import lila.game.{ Game, Pov, PovRef, PlayerRef, GameRepo }
|
||||
import lila.hub.actorApi.map._
|
||||
|
@ -13,7 +14,6 @@ import lila.security.Flood
|
|||
import lila.socket.actorApi.{ Connected ⇒ _, _ }
|
||||
import lila.socket.Handler
|
||||
import lila.user.{ User, Context }
|
||||
import makeTimeout.short
|
||||
|
||||
private[round] final class SocketHandler(
|
||||
roundMap: ActorRef,
|
||||
|
@ -34,16 +34,17 @@ private[round] final class SocketHandler(
|
|||
roundMap ! Tell(gameId, msg)
|
||||
}
|
||||
|
||||
member.playerIdOption.fold[Handler.Controller]({
|
||||
case ("p", o) ⇒ o int "v" foreach { v ⇒ socket ! PingVersion(uid, v) }
|
||||
case ("talk", o) ⇒ for {
|
||||
def watcherTalk(roomId: String, o: JsObject) {
|
||||
for {
|
||||
txt ← o str "d"
|
||||
if flood.allowMessage(uid, txt)
|
||||
} messenger.watcherMessage(
|
||||
ref.gameId,
|
||||
member.userId,
|
||||
txt,
|
||||
member.troll) pipeTo socket
|
||||
} messenger.watcherMessage(roomId, member.userId, txt, member.troll) pipeTo socket
|
||||
}
|
||||
|
||||
member.playerIdOption.fold[Handler.Controller]({
|
||||
case ("p", o) ⇒ o int "v" foreach { v ⇒ socket ! PingVersion(uid, v) }
|
||||
case ("talk", o) ⇒ watcherTalk(ref.gameId, o)
|
||||
case ("talk-tv", o) ⇒ watcherTalk("tv", o)
|
||||
}) { playerId ⇒
|
||||
{
|
||||
case ("p", o) ⇒ o int "v" foreach { v ⇒ socket ! PingVersion(uid, v) }
|
||||
|
|
|
@ -800,6 +800,7 @@ var storage = {
|
|||
self.initTable();
|
||||
self.initClocks();
|
||||
if (self.$chat) self.$chat.chat({
|
||||
talkMessageType: self.options.tv ? 'talk-tv' : 'talk',
|
||||
resize: true,
|
||||
render: function(u, t) {
|
||||
if (self.options.player.spectator) {
|
||||
|
@ -1497,6 +1498,7 @@ var storage = {
|
|||
this.options = $.extend({
|
||||
// render: function(u, t) {},
|
||||
onToggle: function(enabled) {},
|
||||
talkMessageType: 'talk',
|
||||
resize: false
|
||||
}, this.options);
|
||||
var self = this;
|
||||
|
@ -1519,7 +1521,7 @@ var storage = {
|
|||
return false;
|
||||
}
|
||||
$input.val('');
|
||||
lichess.socket.send('talk', text);
|
||||
lichess.socket.send(self.options.talkMessageType, text);
|
||||
return false;
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue