Skip to content

Commit

Permalink
Fix share PGN in analysis offline
Browse files Browse the repository at this point in the history
  • Loading branch information
veloce committed Oct 16, 2016
1 parent 74508b6 commit f3aa365
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 37 deletions.
8 changes: 3 additions & 5 deletions project/src/js/ui/analyse/AnalyseCtrl.ts
Expand Up @@ -14,7 +14,6 @@ import { notesCtrl } from '../shared/round/notes';
import { getPGN } from '../shared/round/roundXhr';
import importPgnPopup from './importPgnPopup';
import * as util from './util';
import { renderStepsTxt } from './pgnExport';
import cevalCtrl from './ceval/cevalCtrl';
import crazyValid from './crazy/crazyValid';
import explorerCtrl from './explorer/explorerCtrl';
Expand Down Expand Up @@ -335,7 +334,8 @@ export default class AnalyseCtrl {
fen: situation.fen,
uci: situation.uciMoves[0],
san: situation.pgnMoves[0],
crazy: situation.crazyhouse
crazy: situation.crazyhouse,
pgnMoves: this.vm.step.pgnMoves ? this.vm.step.pgnMoves.concat(situation.pgnMoves) : undefined
};
const newPath = this.analyse.addStep(step, treePath.read(path));
this.jump(newPath);
Expand Down Expand Up @@ -428,7 +428,7 @@ export default class AnalyseCtrl {
getPGN(this.data.game.id)
.then(pgn => window.plugins.socialsharing.share(pgn))
.catch(handleXhrError);
} else if (this.source === 'offline') {
} else {
const endSituation = this.data.steps[this.data.steps.length - 1];
chess.pgnDump({
variant: this.data.game.variant.key,
Expand All @@ -437,8 +437,6 @@ export default class AnalyseCtrl {
})
.then((res: chess.PgnDumpResponse) => window.plugins.socialsharing.share(res.pgn))
.catch(console.error.bind(console));
} else {
window.plugins.socialsharing.share(renderStepsTxt(this.analyse.getSteps(this.vm.path)));
}
}

Expand Down
3 changes: 2 additions & 1 deletion project/src/js/ui/analyse/data.ts
Expand Up @@ -42,7 +42,8 @@ export function makeDefaultData(fen: string): AnalysisData {
ply,
san: null,
uci: null,
check: false
check: false,
pgnMoves: []
}
]
};
Expand Down
2 changes: 1 addition & 1 deletion project/src/js/ui/analyse/interfaces.ts
Expand Up @@ -6,7 +6,7 @@ export interface SanToRole {
[san: string]: Role
}

export type Source = 'online' | 'offline' | 'fen';
export type Source = 'online' | 'offline';

export interface PathObj {
ply: number
Expand Down
27 changes: 0 additions & 27 deletions project/src/js/ui/analyse/pgnExport.js

This file was deleted.

7 changes: 4 additions & 3 deletions project/src/js/utils/offlineGames.ts
Expand Up @@ -8,9 +8,10 @@ export function getCurrentOTBGame() {
return storage.get(otbStorageKey);
}

export function getAnalyseData(data: StoredOfflineGame) {
export function getAnalyseData(data: StoredOfflineGame): AnalysisData {
if (!data) return null;
data.data.steps = data.situations.map((o: GameSituation) => {
const aData = <AnalysisData>data.data;
aData.steps = data.situations.map((o: GameSituation) => {
const step: AnalysisStep = {
fen: o.fen,
ply: o.ply,
Expand All @@ -25,7 +26,7 @@ export function getAnalyseData(data: StoredOfflineGame) {
};
return step;
});
return data.data;
return aData;
}

export function setCurrentOTBGame(game: StoredOfflineGame): void {
Expand Down

0 comments on commit f3aa365

Please sign in to comment.