From 07d2d1ff2a50b53bab7267eba478d4e44ea2e50f Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Wed, 31 Jul 2013 14:58:43 +0200 Subject: [PATCH] Check if record is in a record array before adding it --- assets/scripts/app/app.coffee | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/assets/scripts/app/app.coffee b/assets/scripts/app/app.coffee index cc177810..99623ecf 100644 --- a/assets/scripts/app/app.coffee +++ b/assets/scripts/app/app.coffee @@ -99,7 +99,9 @@ unless window.TravisApplication result = @loadOrMerge(type, json[root]) if result && result.id record = type.find(result.id) - type.addToRecordArrays(record) + # TODO: find a nicer way to not add record to record arrays twice + if !type._findAllRecordArray || !type._findAllRecordArray.contains(record) + type.addToRecordArrays(record) # 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 @@ -108,7 +110,8 @@ unless window.TravisApplication result = @loadOrMerge(Travis.Repo, json.repository || json.repo) if result && result.id record = Travis.Repo.find(result.id) - Travis.Repo.addToRecordArrays(record) + if !Travis.Repo._findAllRecordArray || !Travis.Repo._findAllRecordArray.contains(record) + Travis.Repo.addToRecordArrays(record) loadOrMerge: (type, hash, options) -> options ||= {}