fix(observables): Fix QuerySubscription to check for clientId's in result set

- See TODO comments
- Fixes #680
- Fixes #681
This commit is contained in:
Juan Tejada 2015-12-22 13:17:22 -08:00
parent ecc1d099d9
commit e9eb530994
2 changed files with 16 additions and 1 deletions

View file

@ -125,7 +125,15 @@ class QuerySubscription
endItem: @_lastResultSet[@_limit - 1]
for item in items
idx = _.findIndex @_lastResultSet, ({id}) -> id is item.id
# TODO
# This logic is duplicated across DatabaseView#invalidate and
# ModelView#indexOf
#
# This duplication should go away when we refactor/replace DatabaseView
# for using observables
idx = _.findIndex @_lastResultSet, ({id, clientId}) ->
id is item.id or item.clientId is clientId
itemIsInSet = idx isnt -1
itemShouldBeInSet = item.matches(@_query.matchers())

View file

@ -206,6 +206,13 @@ class DatabaseView extends ModelView
# of the `id` then we would erroneously say that the item isn't in
# the set. This happens frequently in the DraftListStore when Draft
# items persist on the server and/or turn into Message items.
#
# TODO
# This logic is duplicated across QuerySubscription#_optimisticallyUpdateModels
# and ModelView#indexOf
#
# This duplication should go away when we refactor/replace DatabaseView
# for using observables
idx = @indexOfId(item.clientId)
itemIsInSet = idx isnt -1