mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Merge branch 'mascaraMix' into mascara
This commit is contained in:
commit
54e157020e
@ -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…
Reference in New Issue
Block a user