mirror of
https://github.com/wassname/HackFlowy.git
synced 2026-06-30 16:30:07 +08:00
Uses localstorage db in offline mode
This commit is contained in:
@@ -2,19 +2,30 @@ define(
|
||||
[
|
||||
'backbone',
|
||||
'models/task',
|
||||
'localstorage',
|
||||
'localforage',
|
||||
'localforagebackbone'
|
||||
],
|
||||
|
||||
function(
|
||||
Backbone,
|
||||
Task,
|
||||
LocalStorage
|
||||
localforage,
|
||||
localforageBackbone
|
||||
) {
|
||||
|
||||
var List = Backbone.Collection.extend({
|
||||
|
||||
localStorage: new Backbone.LocalStorage("tasks"),
|
||||
|
||||
model: Task,
|
||||
offlineSync: Backbone.localforage.sync("tasks"),
|
||||
/** switches sync between server and local databases **/
|
||||
sync: function(){
|
||||
if (window.hackflowyOffline)
|
||||
return this.offlineSync.apply(this, arguments);
|
||||
else
|
||||
return Backbone.sync.apply(this, arguments);
|
||||
},
|
||||
|
||||
url: '/tasks'
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user