2017-01-30 21:42:24 +01:00
|
|
|
const ObservableStore = require('obs-store')
|
|
|
|
const normalizeAddress = require('../sig-util').normalize
|
|
|
|
|
|
|
|
class PreferencesController {
|
|
|
|
|
|
|
|
constructor (opts = {}) {
|
|
|
|
const initState = opts.initState || {}
|
|
|
|
this.store = new ObservableStore(initState)
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// PUBLIC METHODS
|
|
|
|
//
|
|
|
|
|
|
|
|
setSelectedAddress(_address) {
|
2017-01-31 00:08:31 +01:00
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
const address = normalizeAddress(_address)
|
|
|
|
this.store.updateState({ selectedAddress: address })
|
|
|
|
resolve()
|
|
|
|
})
|
2017-01-30 21:42:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
getSelectedAddress(_address) {
|
|
|
|
return this.store.getState().selectedAddress
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// PRIVATE METHODS
|
|
|
|
//
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = PreferencesController
|