more types for ui/lobby
This commit is contained in:
parent
bf4615d6e6
commit
4de8f6d910
|
@ -34,6 +34,31 @@ export interface LobbyOpts extends Untyped {
|
||||||
export interface LobbyData extends Untyped {
|
export interface LobbyData extends Untyped {
|
||||||
hooks: Hook[];
|
hooks: Hook[];
|
||||||
seeks: Seek[];
|
seeks: Seek[];
|
||||||
|
nowPlaying: NowPlaying[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface NowPlaying {
|
||||||
|
fullId: string;
|
||||||
|
gameId: string;
|
||||||
|
fen: Fen;
|
||||||
|
color: Color;
|
||||||
|
lastMove: String;
|
||||||
|
variant: {
|
||||||
|
key: string;
|
||||||
|
name: string;
|
||||||
|
};
|
||||||
|
speed: string;
|
||||||
|
perf: string;
|
||||||
|
rated: boolean;
|
||||||
|
hasMoved: boolean;
|
||||||
|
opponent: {
|
||||||
|
id: string;
|
||||||
|
username: string;
|
||||||
|
rating?: number;
|
||||||
|
ai?: number;
|
||||||
|
};
|
||||||
|
isMyTurn: boolean;
|
||||||
|
secondsLeft?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PoolMember {
|
export interface PoolMember {
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
import { h } from 'snabbdom';
|
import { h } from 'snabbdom';
|
||||||
import LobbyController from '../ctrl';
|
import LobbyController from '../ctrl';
|
||||||
|
import { NowPlaying } from '../interfaces';
|
||||||
|
|
||||||
function timer(pov) {
|
function timer(pov: NowPlaying) {
|
||||||
const date = Date.now() + pov.secondsLeft * 1000;
|
const date = Date.now() + pov.secondsLeft! * 1000;
|
||||||
return h('time.timeago', {
|
return h('time.timeago', {
|
||||||
hook: {
|
hook: {
|
||||||
insert(vnode) {
|
insert(vnode) {
|
||||||
|
@ -13,6 +14,7 @@ function timer(pov) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function(ctrl: LobbyController) {
|
export default function(ctrl: LobbyController) {
|
||||||
|
|
||||||
return h('div.now-playing',
|
return h('div.now-playing',
|
||||||
ctrl.data.nowPlaying.map(pov =>
|
ctrl.data.nowPlaying.map(pov =>
|
||||||
h('a.' + pov.variant.key, {
|
h('a.' + pov.variant.key, {
|
||||||
|
|
Loading…
Reference in a new issue