4 .col-sm-12.col-md-10.col-md-offset-1.col-lg-8.col-lg-offset-2
6 button(@click="display='live'") Live games
7 button(@click="display='corr'") Correspondance games
8 GameList(v-show="display=='live'" :games="filterGames('live')"
10 GameList(v-show="display=='corr'" :games="filterGames('corr')"
11 @show-game="showGame")
15 import { store } from "@/store";
16 import { GameStorage } from "@/utils/gameStorage";
17 import { ajax } from "@/utils/ajax";
18 import GameList from "@/components/GameList.vue";
33 GameStorage.getAll((localGames) => {
34 localGames.forEach((g) => g.type = this.classifyObject(g));
35 Array.prototype.push.apply(this.games, localGames);
37 if (this.st.user.id > 0)
39 ajax("/games", "GET", {uid: this.st.user.id}, (res) => {
40 res.games.forEach((g) => g.type = this.classifyObject(g));
41 //Array.prototype.push.apply(this.games, res.games); //TODO: Vue 3
42 this.games = this.games.concat(res.games);
47 // TODO: classifyObject and filterGames are redundant (see Hall.vue)
48 classifyObject: function(o) {
49 return (o.timeControl.indexOf('d') === -1 ? "live" : "corr");
51 filterGames: function(type) {
52 return this.games.filter(g => g.type == type);
54 showGame: function(g) {
55 this.$router.push("/game/" + g.id);
61 <style scoped lang="sass">