remove changes to storage listen

And emit on first stockfish emit.
This commit is contained in:
Isaac Levy 2017-08-14 12:24:54 -04:00
parent 0981e97259
commit 808a2bb3be
2 changed files with 7 additions and 2 deletions

View file

@ -69,12 +69,17 @@ export default function(opts: CevalOpts): CevalController {
};
})();
let lastEmitFen: string | null = null;
const onEmit = throttle(500, false, (ev: Tree.ClientEval, work: Work) => {
sortPvsInPlace(ev.pvs, (work.ply % 2 === (work.threatMode ? 1 : 0)) ? 'white' : 'black');
npsRecorder(ev);
curEval = ev;
opts.emit(ev, work);
if (ev.millis > 1000 && ev.millis < 5000) window.lichess.storage.set('ceval.fen', ev.fen);
if (ev.fen !== lastEmitFen) {
lastEmitFen = ev.fen;
window.lichess.storage.set('ceval.fen', ev.fen);
}
});
const effectiveMaxDepth = function(): number {

View file

@ -49,7 +49,7 @@ lichess.storage = (function() {
},
listen: function(f) {
window.addEventListener('storage', function(e) {
if (e.key === k && e.newValue !== null && e.newValue !== e.oldValue) f(e);
if (e.key === k && e.newValue !== null) f(e);
});
}
};