Skip to content
Snippets Groups Projects
Commit ab6e915f authored by Jacob Poul Richardt's avatar Jacob Poul Richardt
Browse files

Fixed closure bug in CallQueue.

parent 32b56106
No related branches found
No related tags found
No related merge requests found
......@@ -70,7 +70,7 @@ define(["require", "exports", "knockout", "Components/Players/Audio/AudioInfo",
QuestionsBase.prototype.SetAnswer = function (answer) {
this.UpdateIsAnswerValid(answer);
var output = answer;
output.Events = this._events;
output.Events = this._events.map(this.CloneEvent);
this.Model.Answer(output);
};
QuestionsBase.prototype.GetArray = function (data) {
......@@ -106,6 +106,15 @@ define(["require", "exports", "knockout", "Components/Players/Audio/AudioInfo",
};
this._events.push(event);
};
QuestionsBase.prototype.CloneEvent = function (event) {
return {
Id: event.Id,
Type: event.Type,
Method: event.Method,
Data: event.Data,
DateTime: event.DateTime
};
};
QuestionsBase.prototype.TrackAudioInfo = function (id, audioInfo) {
var _this = this;
audioInfo.AddIsPlayingCallback(function (isPlaying) { return _this.AddEvent(isPlaying ? "Start" : "Stop", id, "AudioDevice"); });
......
......@@ -113,7 +113,7 @@ class QuestionsBase<T> implements IQuestionViewModel
this.UpdateIsAnswerValid(answer);
var output = <any>answer;
output.Events = this._events;
output.Events = this._events.map(this.CloneEvent);
this.Model.Answer(output);
}
......@@ -148,7 +148,7 @@ class QuestionsBase<T> implements IQuestionViewModel
return result;
}
protected AddEvent(type:string, id:string = null, method:string = "None", data:string = "None")
protected AddEvent(type:string, id:string = null, method:string = "None", data:string = "None"):void
{
var event = {
Id: id === null ? "None" : id,
......@@ -161,6 +161,17 @@ class QuestionsBase<T> implements IQuestionViewModel
this._events.push(event);
}
private CloneEvent(event:CockpitPortal.IQuestionEvent):CockpitPortal.IQuestionEvent
{
return {
Id: event.Id,
Type: event.Type,
Method: event.Method,
Data: event.Data,
DateTime: event.DateTime
};
}
protected TrackAudioInfo(id:string, audioInfo:AudioInfo):void
{
audioInfo.AddIsPlayingCallback(isPlaying => this.AddEvent(isPlaying ? "Start" : "Stop", id, "AudioDevice"));
......
......@@ -26,8 +26,10 @@ define(["require", "exports"], function (require, exports) {
completed.forEach(function (c) { return c.Complete(success, false); });
if (queue.length === 0)
delete this._queues[id];
else
queue[queue.length - 1].Call(function (s) { return _this.CallNext(id, queue.length, s); });
else {
var newCount = queue.length;
queue[newCount - 1].Call(function (s) { return _this.CallNext(id, newCount, s); });
}
};
return CallQueue;
})();
......
......@@ -39,7 +39,11 @@ class CallQueue
if (queue.length === 0)
delete this._queues[id];
else
queue[queue.length - 1].Call(s => this.CallNext(id, queue.length, s));
{
var newCount = queue.length;
queue[newCount - 1].Call(s => this.CallNext(id, newCount, s));
}
}
}
......
......@@ -5,7 +5,7 @@
<meta charset="utf-8" />
<title>Cockpit Experiments</title>
<script type="text/javascript">
var CacheBuster = 31;
var CacheBuster = 32;
</script>
</head>
<body>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment