in-game simul chat
parent
c5f85f2777
commit
a306cf4208
|
@ -204,13 +204,17 @@ object Round extends LilaController with TheftPrevention {
|
|||
}
|
||||
|
||||
private[controllers] def getPlayerChat(game: GameModel)(implicit ctx: Context): Fu[Option[Chat.GameOrEvent]] = ctx.noKid ?? {
|
||||
game.tournamentId.?? { tid =>
|
||||
ctx.me.??(Tournament.canHaveChat(game.variant, _)) ??
|
||||
(game.tournamentId, game.simulId) match {
|
||||
case (Some(tid), _) => ctx.me.??(Tournament.canHaveChat(game.variant, _)) ??
|
||||
Env.chat.api.userChat.cached.findMine(Chat.Id(tid), ctx.me).map { chat =>
|
||||
Chat.GameOrEvent(Right(chat truncate 50)).some
|
||||
}
|
||||
}.orElse {
|
||||
game.hasChat ?? {
|
||||
case (_, Some(sid)) => game.simulId.?? { sid =>
|
||||
Env.chat.api.userChat.cached.findMine(Chat.Id(sid), ctx.me).map { chat =>
|
||||
Chat.GameOrEvent(Right(chat truncate 50)).some
|
||||
}
|
||||
}
|
||||
case _ => game.hasChat ?? {
|
||||
Env.chat.api.playerChat.findIf(Chat.Id(game.id), !game.justCreated).map { chat =>
|
||||
Chat.GameOrEvent(Left(Chat.Restricted(chat, game.fromLobby && ctx.isAnon))).some
|
||||
}
|
||||
|
|
|
@ -13,7 +13,9 @@ LichessRound.boot({
|
|||
data: @Html(J.stringify(data)),
|
||||
i18n: @jsI18n(pov.game),
|
||||
userId: @jsUserId,
|
||||
tour: @jsOrNull(tour.flatMap(_.top).map(lila.tournament.JsonView.top(_, lightUser))),
|
||||
@tour.map { t =>
|
||||
tour: @toJson(tour.flatMap(_.top).map(lila.tournament.JsonView.top(_, lightUser))),
|
||||
}
|
||||
chat: @jsOrNull(chatOption.map(_.either).map {
|
||||
case Left(c) => {
|
||||
chat.ChatJsData.restricted(c, name = trans.chatRoom.txt(), timeout = false, withNote = ctx.isAuth, public = false)
|
||||
|
|
|
@ -78,6 +78,7 @@ export interface Tournament {
|
|||
}
|
||||
|
||||
export interface Simul {
|
||||
id: string;
|
||||
name: string;
|
||||
hostId: string;
|
||||
nbPlaying: number;
|
||||
|
|
|
@ -6,7 +6,7 @@ import { tourStandingCtrl, TourStandingCtrl } from './tourStanding';
|
|||
const li = window.lichess;
|
||||
|
||||
export default function(opts: RoundOpts, element: HTMLElement): void {
|
||||
const data = opts.data;
|
||||
const data: RoundData = opts.data;
|
||||
li.openInMobileApp(data.game.id);
|
||||
let round: RoundApi, chat: ChatCtrl | undefined;
|
||||
if (data.tournament) $('body').data('tournament-id', data.tournament.id);
|
||||
|
@ -65,7 +65,7 @@ export default function(opts: RoundOpts, element: HTMLElement): void {
|
|||
};
|
||||
opts.element = element.querySelector('.round') as HTMLElement;
|
||||
opts.socketSend = li.socket.send;
|
||||
if (!opts.tour) opts.onChange = (d: RoundData) => {
|
||||
if (!opts.tour && !data.simul) opts.onChange = (d: RoundData) => {
|
||||
if (chat) chat.preset.setGroup(getPresetGroup(d));
|
||||
};
|
||||
opts.crosstableEl = element.querySelector('.crosstable') as HTMLElement;
|
||||
|
@ -77,7 +77,7 @@ export default function(opts: RoundOpts, element: HTMLElement): void {
|
|||
if (opts.tour) {
|
||||
opts.chat.plugin = tourStandingCtrl(opts.tour, opts.i18n.standing);
|
||||
opts.chat.alwaysEnabled = true;
|
||||
} else {
|
||||
} else if (!data.simul) {
|
||||
opts.chat.preset = getPresetGroup(opts.data);
|
||||
opts.chat.parseMoves = true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue