@@ -205,7 +205,8 @@ dualsync = (method, model, options) ->
205
205
console .log " can't clear" , options .storeName , " require sync dirty data first"
206
206
success localsync (method, model, options)
207
207
else
208
- options .success = (resp , status , xhr ) ->
208
+ remoteOptions = _ (options).clone ()
209
+ remoteOptions .success = (resp , status , xhr ) ->
209
210
console .log ' got remote' , resp, ' putting into' , options .storeName
210
211
resp = parseRemoteResponse (model, resp)
211
212
@@ -218,13 +219,24 @@ dualsync = (method, model, options) ->
218
219
else
219
220
localsync (' create' , resp, options)
220
221
221
- success (resp, status, xhr)
222
+ success (resp, status, xhr) # ideally this would only be called if we knew that it was different from localStorage, instead of reset()-ing
222
223
223
- options .error = (resp ) ->
224
- console .log ' getting local from' , options .storeName
225
- success localsync (method, model, options)
226
-
227
- onlineSync (method, model, options)
224
+ remoteOptions .error = (resp ) ->
225
+ console .log (' remote sync failed, doing nothing' )
226
+
227
+ # after localsync loads, check to see if we should still remotesync
228
+ options .ignoreCallbacks = false
229
+ options .success = (resp ) ->
230
+ # first fire the success callback which will populate the model
231
+ success (resp)
232
+
233
+ # now that the collection is populated from localStorage, check if we should remote
234
+ if _ .isUndefined (model .shouldRemoteSync ) or (_ .isFunction (model .shouldRemoteSync ) and model .shouldRemoteSync ())
235
+ onlineSync (method, model, remoteOptions)
236
+
237
+
238
+ console .log ' getting local from' , options .storeName
239
+ localsync (method, model, options)
228
240
229
241
when ' create'
230
242
options .success = (resp , status , xhr ) ->
0 commit comments