Do not trigger callbacks if a object got refreshed and is still the same.
This commit is contained in:
parent
2c74ea2f61
commit
611161c76c
1 changed files with 21 additions and 2 deletions
|
@ -291,7 +291,7 @@ class App.Model extends Spine.Model
|
|||
|
||||
# subscribe and render data after local change
|
||||
@bind(
|
||||
'refresh change'
|
||||
'change'
|
||||
(items) =>
|
||||
|
||||
# check if result is array or singel item
|
||||
|
@ -301,7 +301,26 @@ class App.Model extends Spine.Model
|
|||
for item in items
|
||||
for key, callback of App[ @className ].SUBSCRIPTION_ITEM[ item.id ]
|
||||
item = App[ @className ]._fillUp( item )
|
||||
callback(item)
|
||||
callback(item, 'change')
|
||||
)
|
||||
|
||||
@changeTable = {}
|
||||
@bind(
|
||||
'refresh'
|
||||
(items) =>
|
||||
|
||||
# check if result is array or singel item
|
||||
if !_.isArray(items)
|
||||
items = [items]
|
||||
|
||||
for item in items
|
||||
for key, callback of App[ @className ].SUBSCRIPTION_ITEM[ item.id ]
|
||||
|
||||
# only trigger callbacks if object has changed
|
||||
if !@changeTable[key] || @changeTable[key] isnt item.updated_at
|
||||
@changeTable[key] = item.updated_at
|
||||
item = App[ @className ]._fillUp( item )
|
||||
callback(item, 'refresh')
|
||||
)
|
||||
|
||||
# subscribe and render data after server change
|
||||
|
|
Loading…
Reference in a new issue