From c8a475f3565a3bf038fdd080cdbfd9000d98ccc3 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 5 Sep 2016 12:03:17 +0200 Subject: [PATCH] Do updated_at lookup in callback (minimise race condition time). --- .../javascripts/app/models/_application_model.coffee | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/app/models/_application_model.coffee b/app/assets/javascripts/app/models/_application_model.coffee index 96900e20e..373c828bc 100644 --- a/app/assets/javascripts/app/models/_application_model.coffee +++ b/app/assets/javascripts/app/models/_application_model.coffee @@ -455,15 +455,15 @@ class App.Model extends Spine.Model events (item) => if @SUBSCRIPTION_ITEM && @SUBSCRIPTION_ITEM[ item.id ] - genericObject = undefined - if App[ @className ].exists(item.id) - genericObject = App[ @className ].find(item.id) App.Log.debug('Model', "server change on #{@className}.find(#{item.id}) #{item.updated_at}") callback = => - if !genericObject || new Date(item.updated_at) >= new Date(genericObject.updated_at) + genericObject = undefined + if App[ @className ].exists(item.id) + genericObject = App[ @className ].find(item.id) + if !genericObject || new Date(item.updated_at) > new Date(genericObject.updated_at) App.Log.debug('Model', "request #{@className}.find(#{item.id}) from server") @full(item.id, false, true) - App.Delay.set(callback, 500, item.id, "full-#{@className}-#{item.id}") + App.Delay.set(callback, 600, item.id, "full-#{@className}-#{item.id}") "Item::Subscribe::#{@className}" )