1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Make the function callback friendly.

This commit is contained in:
Kevin Serrano 2017-10-10 08:36:15 -07:00
parent f6821781d2
commit 24a55cf777
No known key found for this signature in database
GPG Key ID: BF999DEFC7371BA1
3 changed files with 15 additions and 8 deletions

View File

@ -19,13 +19,13 @@ class ExtensionPlatform {
getPlatformInfo (cb) { getPlatformInfo (cb) {
try { try {
return extension.runtime.getPlatformInfo(cb) extension.runtime.getPlatformInfo((platform) => {
cb(null, platform)
})
} catch (e) { } catch (e) {
log.debug(e) cb(e)
return undefined
} }
} }
} }
module.exports = ExtensionPlatform module.exports = ExtensionPlatform

View File

@ -113,8 +113,12 @@ ConfigScreen.prototype.render = function () {
alignSelf: 'center', alignSelf: 'center',
}, },
onClick (event) { onClick (event) {
window.logStateString((result) => { window.logStateString((err, result) => {
if (err) {
state.dispatch(actions.displayWarning('Error in retrieving state logs.'))
} else {
exportAsFile('MetaMask State Logs', result) exportAsFile('MetaMask State Logs', result)
}
}) })
}, },
}, 'Download State Logs'), }, 'Download State Logs'),

View File

@ -45,12 +45,15 @@ window.logStateString = function (cb) {
let state = window.METAMASK_CACHED_LOG_STATE let state = window.METAMASK_CACHED_LOG_STATE
const version = global.platform.getVersion() const version = global.platform.getVersion()
const browser = window.navigator.userAgent const browser = window.navigator.userAgent
return global.platform.getPlatformInfo((platform) => { return global.platform.getPlatformInfo((err, platform) => {
if (err) {
return cb(err)
}
state.version = version state.version = version
state.platform = platform state.platform = platform
state.browser = browser state.browser = browser
let stateString = JSON.stringify(state, removeSeedWords, 2) let stateString = JSON.stringify(state, removeSeedWords, 2)
return cb(stateString) return cb(null, stateString)
}) })
} }