-
Notifications
You must be signed in to change notification settings - Fork 108
Destroyed model not being cleared after online sync #146
Comments
Mentioned the wrong issue in the commit that closed this. Whoops! |
Here's what generally happens (I'll go through
The two places I can see this might be going wrong:
noted. I also would like to improve the ease of understanding. |
Let's say I have POSTed an item and am online.
I go offline and delete it, and then go back online.
The item is deleted from the server. So far so good.
Then I go offline and back online. A
syncDirtyAndDestroyed
is triggered and the server tries to delete the item that it already deleted.So it looks like after the online sync, the destroyed model id isn't being cleared from the store.
I will post more info later today.
Edit:
syncDirtyAndDestroyed
is called which in turn callssyncDestroyed
. After the model has been destroyed on the server, I would expectstoreName_destroyed
to not exist.syncDestroyed
gets the destroyed models (local not online it seems) by callinglocalStorage.getItem((getStoreName(this)) + "_destroyed");
underBackbone.Collection.prototype.syncDestroyed
.This shouldn't find anything, but it does, suggesting that
localStorage.removeItem
is not called.I found
localStorage.removeItem
in two places - once whenStore.prototype.clear
is called and once whenStore.prototype.destroy(model)
is called, the latter I think is the one that is important here.So when is
store.destroy
being called?I would expect this to be called after the online sync is complete. (delete offline - removed from localstorage; go online -
syncDestroyed
- finds a_destroyed
item and deletes from server; that model is removed so no model belongs tostoreName_destroyed
anymore; offline; online -syncDestroyed
- find nothing).It is being called in two places:
Backbone.LocalStorage.sync
andlocalsync
.I don't quite understand why a local sync should remove that item rather than an online sync.
What am I missing?
Though I understand you're busy, comments in the code would help.
The text was updated successfully, but these errors were encountered: