mirror of
https://github.com/wassname/HackFlowy.git
synced 2026-07-21 12:20:42 +08:00
Fix for offline sync
This commit is contained in:
@@ -13,22 +13,30 @@ localforage,
|
||||
localforageBackbone
|
||||
) {
|
||||
|
||||
var List = Backbone.Collection.extend({
|
||||
var List = Backbone.Collection.extend({
|
||||
|
||||
|
||||
model: Task,
|
||||
offlineSync: Backbone.localforage.sync("tasks"),
|
||||
/** switches sync between server and local databases **/
|
||||
sync: function(){
|
||||
model: Task,
|
||||
offlineSync: Backbone.localforage.sync("tasks"),
|
||||
/** switches sync between server and local databases **/
|
||||
sync: function(){
|
||||
//var self = this;
|
||||
_localforageNamespace = this.offlineSync._localforageNamespace;
|
||||
_localeForageKeyFn=this.offlineSync._localeForageKeyFn;
|
||||
localforageKey = this.offlineSync._localeForageKeyFn;
|
||||
if (window.hackflowyOffline)
|
||||
return this.offlineSync.apply(this, arguments);
|
||||
else
|
||||
return Backbone.sync.apply(this, arguments);
|
||||
},
|
||||
},
|
||||
|
||||
url: '/tasks'
|
||||
url: '/tasks'
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
// a couple of vars backbone.localforage needs in the sync function
|
||||
List.prototype.sync.localforage = List.prototype.offlineSync._localeForageKeyFn;
|
||||
List.prototype.sync._localeForageKeyFn = List.prototype.offlineSync._localeForageKeyFn;
|
||||
List.prototype.sync._localforageNamespace = List.prototype.offlineSync._localforageNamespace;
|
||||
|
||||
return List;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user