Skip to content

Commit c281de4

Browse files
committed
Address race conditions if you finish an attempt before the first scramble is ready (#57).
1 parent c703b58 commit c281de4

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

cubing.js

+3
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ Cubing.Scramblers.prototype = {
111111
{
112112
var callback = this._commandIdToCallback[e.data.commandId];
113113
delete this._commandIdToCallback[e.data.commandId];
114+
// TODO: Handle race conditions if the first attempt is done before the
115+
// first scramble returns (possibly don't allow starting the timer without
116+
// a valid scramble?).
114117
callback(e.data.scramble)
115118
}
116119
}

timerApp.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ TimerApp.prototype = {
106106
var dateString = today.getFullYear() + "-" + (today.getMonth() + 1) + "-" + today.getDate();
107107

108108
var serializationFormat = "v0.1";
109-
var result = "[" + serializationFormat + "][" + this._currentEvent + "][" + new Date() + "] " + (time / 1000) + " (" + this._currentScramble.scrambleString + ")";
109+
var scrambleString = this._currentScramble ? this._currentScramble.scrambleString : "/* no scramble */";
110+
var result = "[" + serializationFormat + "][" + this._currentEvent + "][" + new Date() + "] " + (time / 1000) + " (" + scrambleString + ")";
110111

111112
var store = (dateString in localStorage) ? localStorage[dateString] + "\n" : "";
112113
localStorage[dateString] = store + result;

0 commit comments

Comments
 (0)