ui/simul fixes and tweaks

pull/7157/head
Thibault Duplessis 2020-08-20 21:42:44 +02:00
parent 92658a041f
commit c4d9cc74b5
4 changed files with 7 additions and 10 deletions

View File

@ -17,7 +17,6 @@
},
"dependencies": {
"chat": "2.0.0",
"chessground": "^7.9.1",
"common": "2.0.0",
"game": "2.0.0",
"snabbdom": "^0.7.4"

View File

@ -13,6 +13,7 @@ export default class SimulCtrl {
socket: SimulSocket;
constructor(readonly opts: SimulOpts, readonly redraw: () => void) {
this.data = opts.data;
this.trans = window.lichess.trans(opts.i18n);
this.socket = makeSocket(opts.socketSend, this);
if (this.createdByMe() && this.data.isCreated)

View File

@ -2,7 +2,6 @@ import { init } from 'snabbdom';
import { VNode } from 'snabbdom/vnode'
import cls from 'snabbdom/modules/class';
import attributes from 'snabbdom/modules/attributes';
import { Chessground } from 'chessground';
import { SimulOpts } from './interfaces';
import SimulCtrl from './ctrl';
import LichessChat from 'chat';
@ -13,10 +12,10 @@ import view from './view/main';
export function start(opts: SimulOpts) {
const li = window.lichess;
const element = document.querySelector('main.swiss') as HTMLElement;
const element = document.querySelector('main.simul') as HTMLElement,
li = window.lichess;
li.socket = li.StrongSocket(
`/simul/${opts.data.id}`, opts.socketVersion, {
`/simul/${opts.data.id}/socket/v4`, opts.socketVersion, {
receive: (t: string, d: any) => ctrl.socket.receive(t, d)
});
opts.classes = element.getAttribute('class').replace(' ', '.');
@ -39,7 +38,5 @@ export function start(opts: SimulOpts) {
redraw();
};
// that's for the rest of lichess to access chessground
// without having to include it a second time
window.Chessground = Chessground;
// that's for the rest of lichess to access the chat
window.LichessChat = LichessChat;

View File

@ -13,7 +13,7 @@ export default function(showText: (ctrl: SimulCtrl) => VNode) {
return [
h('div.box__top', [
util.title(ctrl),
h('div.box__top__actions', [
h('div.box__top__actions',
ctrl.opts.userId ? (
isHost ? [
startOrCancel(ctrl, accepted),
@ -47,7 +47,7 @@ export default function(showText: (ctrl: SimulCtrl) => VNode) {
href: '/login?referrer=' + window.location.pathname
}
}, ctrl.trans('signIn'))
])
)
]),
showText(ctrl),
ctrl.acceptedContainsMe() ? h('p.instructions',