remove last 4 tournament games miniboards

This commit is contained in:
Thibault Duplessis 2016-01-25 19:38:32 +07:00
parent dcfc589b52
commit bca06ddcfc
6 changed files with 8 additions and 56 deletions

View file

@ -17,7 +17,6 @@ final class JsonView(
private case class CachableData(
pairings: JsArray,
games: JsArray,
featured: Option[JsObject],
podium: Option[JsArray])
@ -55,7 +54,6 @@ final class JsonView(
"secondsToStart" -> tour.isCreated.option(tour.secondsToStart),
"startsAt" -> tour.isCreated.option(ISODateTimeFormat.dateTime.print(tour.startsAt)),
"pairings" -> data.pairings,
"lastGames" -> data.games,
"standing" -> stand,
"me" -> myInfo.map(myInfoJson),
"featured" -> data.featured,
@ -153,13 +151,11 @@ final class JsonView(
private val cachableData = lila.memo.AsyncCache[String, CachableData](id =>
for {
pairings <- PairingRepo.recentByTour(id, 40)
games <- GameRepo games pairings.take(4).map(_.gameId)
tour <- TournamentRepo byId id
featured <- tour ?? fetchFeaturedGame
podium <- podiumJson(id)
} yield CachableData(
JsArray(pairings map pairingJson),
JsArray(games map gameJson),
featured map featuredJson,
podium),
timeToLive = 1 second)
@ -199,14 +195,6 @@ final class JsonView(
).noNull
}
private def gameJson(g: Game) = Json.obj(
"id" -> g.id,
"fen" -> (chess.format.Forsyth exportBoard g.toChess.board),
"color" -> g.firstColor.name,
"lastMove" -> ~g.castleLastMoveTime.lastMoveString,
"user1" -> gameUserJson(g.firstPlayer),
"user2" -> gameUserJson(g.secondPlayer))
private def scheduleJson(s: Schedule) = Json.obj(
"freq" -> s.freq.name,
"speed" -> s.speed.name)

View file

@ -38,7 +38,7 @@ module.exports = function(env) {
this.vm.playerInfo.data = data.playerInfo;
this.loadPage(data.standing);
if (this.vm.focusOnMe) this.scrollToMe();
startWatching();
data.featured && startWatching(data.featured.id);
sound.end(this.data);
sound.countDown(this.data);
this.vm.joinLoader = false;
@ -79,21 +79,14 @@ module.exports = function(env) {
this.vm.focusOnMe = true;
}.bind(this);
var alreadyWatching = [];
var startWatching = function() {
var newIds = this.data.lastGames.map(function(p) {
return p.id;
}).filter(function(id) {
return alreadyWatching.indexOf(id) === -1;
});
if (newIds.length) {
var watchingGameId;
var startWatching = function(id) {
if (id !== watchingGameId) {
setTimeout(function() {
this.socket.send("startWatching", newIds.join(' '));
this.socket.send("startWatching", id);
}.bind(this), 1000);
newIds.forEach(alreadyWatching.push.bind(alreadyWatching));
}
}.bind(this);
startWatching();
this.scrollToMe = function() {
if (!this.data.me) return;

View file

@ -12,8 +12,7 @@ module.exports = {
return [
util.title(ctrl),
arena.podium(ctrl),
arena.standing(ctrl, pag),
util.games(ctrl.data.lastGames)
arena.standing(ctrl, pag)
];
},
side: function(ctrl) {

View file

@ -15,11 +15,7 @@ function user(p, it) {
}
function featured(f, n) {
return m('div.featured', {
config: function(el, isUpdate, ctx) {
if (ctx.id !== f.id) $('body').trigger('lichess.content_loaded');
}
}, [
return m('div.featured', [
m('div.vstext.top', [
m('strong', '#' + f.player2.rank),
util.player(f.player2)

View file

@ -23,8 +23,7 @@ module.exports = {
'You are playing!',
m('span.text[data-icon=G]', ctrl.trans('joinTheGame'))
]) : null,
arena.standing(ctrl, pag),
util.games(ctrl.data.lastGames)
arena.standing(ctrl, pag)
];
},
side: function(ctrl) {

View file

@ -17,26 +17,6 @@ function miniBoard(game) {
}, boardContent);
}
function miniGame(game) {
return m('div', [
miniBoard(game),
m('div.vstext.clearfix', [
m('div.left', [
game.user1.name,
m('br'),
game.user1.title ? game.user1.title + ' ' : '',
game.user1.rating
]),
m('div.right', [
game.user2.name,
m('br'),
game.user2.rating,
game.user2.title ? ' ' + game.user2.title : ''
])
])
]);
}
module.exports = {
title: function(ctrl) {
if (ctrl.data.schedule && ctrl.data.schedule.freq.indexOf('marathon') !== -1)
@ -91,9 +71,6 @@ module.exports = {
]
};
},
games: function(games) {
return m('div.game_list.playing', games.map(miniGame));
},
miniBoard: miniBoard,
clock: function(time) {
return function(el, isUpdate) {