Skip to content
Browse files

Clean up, and ensure we always load record into RA.

  • Loading branch information...
1 parent f6223fe commit 3b48187a62fd7903de284014a2f09765a51ebadd @cmeiklejohn cmeiklejohn committed Jan 8, 2013
Showing with 20 additions and 10 deletions.
  1. +6 −10 assets/javascripts/app/events.js
  2. +14 −0 assets/javascripts/app/models.js
View
16 assets/javascripts/app/events.js
@@ -4,23 +4,19 @@ GiddyUp.EventProcessor = Ember.Object.extend({
this.source.addEventListener('test_result', function(e) {
var parsedResponse = JSON.parse(e.data);
- var testResult = parsedResponse.test_result;
-
- // Load the new test result into the store.
- //
- GiddyUp.store.load(GiddyUp.TestResult, testResult);
+ var rawTestResult = parsedResponse.test_result;
+ var testResult = GiddyUp.TestResult.loadRawTestResult(
+ rawTestResult);
// Notification handling.
//
if (window.webkitNotifications &&
window.webkitNotifications.checkPermission() === 0) {
-
- var result = GiddyUp.TestResult.find(testResult.id);
- var message = result.get('notification');
+ var message = testResult.get('notification');
window.webkitNotifications.createNotification(
- "icon.png", message.title, message.message
- ).show();
+ "icon.png", message.title, message.message).
+ show();
}
});
}
View
14 assets/javascripts/app/models.js
@@ -90,6 +90,20 @@ GiddyUp.TestResult = DS.Model.extend({
}.property()
});
+GiddyUp.TestResult.reopenClass({
+ /** Load record, immediately materialize, and force listening array
+ ** proxies to reference object. */
+ loadRawTestResult: function(rawTestResult) {
+ var newTestResult = GiddyUp.store.load(GiddyUp.TestResult,
+ rawTestResult);
+ var testResult = GiddyUp.TestResult.find(newTestResult.id);
+
+ testResult.get('test_instance.test_results').pushObject(testResult);
+
+ return testResult;
+ }
+});
+
GiddyUp.Log = DS.Model.extend({
body: DS.attr('string'),

0 comments on commit 3b48187

Please sign in to comment.
Something went wrong with that request. Please try again.