Merge branch 'mascaraMix' into mascara

feature/default_network_editable
frankiebee 8 years ago
commit 54e157020e
  1. 23
      library/controllers/index-db-controller.js
  2. 12
      library/sw-core.js

@ -67,28 +67,17 @@ module.exports = class IndexDbController extends EventEmitter {
})
}
put (key, state) {
return this.requestObjectStore(key, 'readwrite')
put (state) {
return this.requestObjectStore('dataStore', 'readwrite')
.then((dataObject)=> {
return new Promise((resolve, reject) => {
try {
const serialized = JSON.stringify(state)
const putRequest = dataObject.put(serialized)
putRequest.onsuccess = (event) => resolve(event.currentTarget.result)
putRequest.onerror = (event) => reject(event)
} catch (err) {
reject(err)
}
})
const putRequest = dataObject.put(state, 'dataStore')
putRequest.onsuccess = (event) => Promise.resolve(event.currentTarget.result)
putRequest.onerror = (event) => Promise.reject(event)
})
}
update (key, value) {
}
migrate () {
this.db.createObjectStore(this.name)
this.db.createObjectStore('dataStore')
}
_add (key, objStore, cb = logger) {

@ -87,7 +87,7 @@ function loadStateFromPersistence() {
const initialState = migrator.generateInitialState(firstTimeState)
dbController.initialState = initialState
return dbController.open()
.then((stuff) => {
.then((openRequest) => {
return dbController.get('dataStore')
})
.then((data) => {
@ -142,13 +142,13 @@ function setupController (initState, client) {
// diskStore
// )
controller.store.subscribe((state) => {
dbController.put('dataStore', state)
// .then((event) => {debugger})
// .catch((err) => {debugger})
dbController.put(versionifyData(controller.store))
.catch((err) => {console.error(err)})
})
function versionifyData(state) {
let versionedData = diskStore.getState()
versionedData.data = state
// let versionedData = diskStore.getState()
// versionedData.data = state
let versionedData = {data: state}
return versionedData
}

Loading…
Cancel
Save