@show-game="showGame"
@abortgame="abortGame"
)
+ UploadGame(
+ v-show="display=='import'"
+ @game-uploaded="addGameImport"
+ )
GameList(
v-show="display=='import'"
ref="importgames"
@click="loadMore(display)"
)
| {{ st.tr["Load more"] }}
- UploadGame(@game-uploaded="addGameImport")
</template>
<script>
// Now ask completed games (partial list)
this.loadMore(
"live",
- () => this.loadMore("corr", adjustAndSetDisplay)
+ () => this.loadMore("corr", () => {
+ this.loadMore("import", adjustAndSetDisplay);
+ })
);
}
}
);
- } else this.loadMore("live", adjustAndSetDisplay);
+ }
+ else {
+ this.loadMore("live", () => {
+ this.loadMore("import", adjustAndSetDisplay);
+ });
+ }
});
},
beforeDestroy: function() {
let elt = e ? e.target : document.getElementById(type + "Games");
elt.classList.add("active");
elt.classList.remove("somethingnew"); //in case of
- if (elt.previousElementSibling)
- elt.previousElementSibling.classList.remove("active");
- else elt.nextElementSibling.classList.remove("active");
+ for (let t of ["live","corr","import"]) {
+ if (t != type)
+ document.getElementById(t + "Games").classList.remove("active");
+ }
},
addGameImport(game) {
- if (!game.id) {
- alert(this.st.tr[
- "No identifier found: use the upload button in analysis mode"]);
- }
- else this.importGames.push(game);
+ game.type = "import";
+ ImportgameStorage.add(game, (err) => {
+ if (!!err) {
+ if (err.message.indexOf("Key already exists") < 0) {
+ alert(this.st.tr["An error occurred. Try again!"]);
+ return;
+ }
+ else alert(this.st.tr["The game was already imported"]);
+ }
+ this.$router.push("/game/" + game.id);
+ });
},
tryShowNewsIndicator: function(type) {
if (
- (type == "live" && this.display == "corr") ||
- (type == "corr" && this.display == "live")
+ (type == "live" && this.display != "live") ||
+ (type == "corr" && this.display != "corr")
) {
document
.getElementById(type + "Games")