{"action":"closed","issue":{"url":"https://api.github.com/repos/nilbus/Backbone.dualStorage/issues/147","labels_url":"https://api.github.com/repos/nilbus/Backbone.dualStorage/issues/147/labels{/name}","comments_url":"https://api.github.com/repos/nilbus/Backbone.dualStorage/issues/147/comments","events_url":"https://api.github.com/repos/nilbus/Backbone.dualStorage/issues/147/events","html_url":"https://github.com/nilbus/Backbone.dualStorage/issues/147","id":99235587,"number":147,"title":"Dirty/Destroyed models not be cleared from localStorage after an online sync.","user":{"login":"pushkin-","id":6374473,"avatar_url":"https://avatars.githubusercontent.com/u/6374473?v=3","gravatar_id":"","url":"https://api.github.com/users/pushkin-","html_url":"https://github.com/pushkin-","followers_url":"https://api.github.com/users/pushkin-/followers","following_url":"https://api.github.com/users/pushkin-/following{/other_user}","gists_url":"https://api.github.com/users/pushkin-/gists{/gist_id}","starred_url":"https://api.github.com/users/pushkin-/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pushkin-/subscriptions","organizations_url":"https://api.github.com/users/pushkin-/orgs","repos_url":"https://api.github.com/users/pushkin-/repos","events_url":"https://api.github.com/users/pushkin-/events{/privacy}","received_events_url":"https://api.github.com/users/pushkin-/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-08-05T15:45:26Z","updated_at":"2015-08-12T12:02:37Z","closed_at":"2015-08-12T12:02:37Z","body":"Related to #146 \r\nLet's say I have a model in localStorage. Its key would be something like `http://ip/some/path/stuff_dirty`.\r\n\r\nWhen I come back online and call `syncDirtyAndDestroyed`, I expect all the `_dirty` (and `_destroyed`) models to be cleared from localStorage. However, this does not happen.\r\n\r\nPerhaps this changes something, but I'm testing this from the console. I'm calling `mystore.save(somemodel)` and then disconnecting and reconnecting twice. Both times it tries to sync that model (2 POSTS).\r\n\r\nI feel like there should be a `window.localStorage.clear()` after the `syncDirtyAndDestroyed` (at the end of). Of course it would have to be implemented more carefully, because if the sync fails, localstorage would still be cleared. It would need to remove only the models that were successfully synced.\r\n\r\n**Edit:**\r\nActually, I see now that `syncDirty` calls `save` which in turn calls `dualsync`. Something in there should be clearing localStorage."}}