From 81898e422ffa1aaa5f8425def0b3935d287d9447 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Thu, 12 Nov 2015 16:02:51 +0100 Subject: [PATCH] Fix pusher to work with new ember-data This commit just fixes things to the point where pusher updates are applied to the store properly. This still lacks a business logic fixes, so for example we won't update lastBuild's field, because there's no such information from pusher. --- app/services/store.coffee | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/services/store.coffee b/app/services/store.coffee index 60931a80..a5e96a63 100644 --- a/app/services/store.coffee +++ b/app/services/store.coffee @@ -47,8 +47,10 @@ Store = DS.Store.extend return unless @canHandleEvent(event, data) + console.log(event, data) + if name == 'job' && data.job?.commit - @pushPayload(commits: [data.job.commit]) + @push(this.normalize('commit', data.job.commit)) if name == 'build' && data.build?.commit # TODO: commit should be a sideload record on build, not mixed with it @@ -67,7 +69,7 @@ Store = DS.Store.extend } delete(data.build.commit) - @pushPayload(commits: [commit]) + @push(this.normalize('commit', commit)) if event == 'job:log' data = data.job @@ -81,13 +83,13 @@ Store = DS.Store.extend _loadOne: (type, json) -> payload = {} payload[type.pluralize()] = [json[type]] - @pushPayload(payload) + @push(this.normalize(type, json)) # we get other types of records only in a few situations and # it's not always needed to update data, so I'm specyfing which # things I want to update here: if type == 'build' && (json.repository || json.repo) data = json.repository || json.repo - @pushPayload(repos: [data]) + @push(this.normalize('repo', data)) `export default Store`