error and auth fixes

This commit is contained in:
Jeremy Kauffman 2017-05-24 17:53:03 -04:00
parent 6e414c93ce
commit 0c41cbb823
9 changed files with 22 additions and 14 deletions

View file

@ -208,12 +208,13 @@ export function doCheckUpgradeAvailable() {
export function doAlertError(errorList) { export function doAlertError(errorList) {
return function(dispatch, getState) { return function(dispatch, getState) {
const state = getState() const state = getState()
console.log('do alert error')
console.log(errorList)
dispatch({ dispatch({
type: types.OPEN_MODAL, type: types.OPEN_MODAL,
data: { data: {
modal: 'error', modal: 'error',
error: errorList extraContent: errorList
} }
}) })
} }

View file

@ -6,6 +6,7 @@ import {
} from 'selectors/app' } from 'selectors/app'
import { import {
doCheckUpgradeAvailable, doCheckUpgradeAvailable,
doAlertError,
} from 'actions/app' } from 'actions/app'
import { import {
doUpdateBalance, doUpdateBalance,
@ -17,6 +18,7 @@ const select = (state) => ({
}) })
const perform = (dispatch) => ({ const perform = (dispatch) => ({
alertError: (errorList) => dispatch(doAlertError(errorList)),
checkUpgradeAvailable: () => dispatch(doCheckUpgradeAvailable()), checkUpgradeAvailable: () => dispatch(doCheckUpgradeAvailable()),
updateBalance: (balance) => dispatch(doUpdateBalance(balance)) updateBalance: (balance) => dispatch(doUpdateBalance(balance))
}) })

View file

@ -178,7 +178,7 @@ const ErrorStage = (props) => {
return <section> return <section>
<p>An error was encountered that we cannot continue from.</p> <p>An error was encountered that we cannot continue from.</p>
<p>At least we're earning the name beta.</p> <p>At least we're earning the name beta.</p>
{ this.props.errorText ? <p>Message: {props.errorText}</p> : '' } { props.errorText ? <p>Message: {props.errorText}</p> : '' }
<Link button="alt" label="Try Reload" onClick={() => { window.location.reload() } } /> <Link button="alt" label="Try Reload" onClick={() => { window.location.reload() } } />
</section> </section>
} }

View file

@ -4,7 +4,7 @@ import {
} from 'react-redux' } from 'react-redux'
import { import {
selectCurrentModal, selectCurrentModal,
selectError, selectModalExtraContent,
} from 'selectors/app' } from 'selectors/app'
import { import {
doCloseModal, doCloseModal,
@ -13,7 +13,7 @@ import ErrorModal from './view'
const select = (state) => ({ const select = (state) => ({
modal: selectCurrentModal(state), modal: selectCurrentModal(state),
error: selectError(state), error: selectModalExtraContent(state),
}) })
const perform = (dispatch) => ({ const perform = (dispatch) => ({

View file

@ -9,10 +9,12 @@ class ErrorModal extends React.Component {
const { const {
modal, modal,
closeModal, closeModal,
error, error
} = this.props } = this.props
const _error_key_labels = { const errorObj = typeof error === "string" ? { error: error } : error
const error_key_labels = {
connectionString: 'API connection string', connectionString: 'API connection string',
method: 'Method', method: 'Method',
params: 'Parameters', params: 'Parameters',
@ -20,13 +22,15 @@ class ErrorModal extends React.Component {
message: 'Error message', message: 'Error message',
data: 'Error data', data: 'Error data',
} }
const errorInfo = <ul className="error-modal__error-list"></ul>
const errorInfoList = [] const errorInfoList = []
for (let key of Object.keys(error)) { for (let key of Object.keys(error)) {
let val = typeof error[key] == 'string' ? error[key] : JSON.stringify(error[key]); let val = typeof error[key] == 'string' ? error[key] : JSON.stringify(error[key]);
let label = this._error_key_labels[key]; let label = error_key_labels[key];
errorInfoList.push(<li key={key}><strong>{label}</strong>: <code>{val}</code></li>); errorInfoList.push(<li key={key}><strong>{label}</strong>: <code>{val}</code></li>);
} }
const errorInfo = <ul className="error-modal__error-list">{errorInfoList}</ul>
return( return(
<ExpandableModal <ExpandableModal

View file

@ -110,6 +110,7 @@ lbryio.authenticate = function() {
lbry.status().then((response) => { lbry.status().then((response) => {
let installation_id = response.installation_id; let installation_id = response.installation_id;
installation_id = installation_id.substring(0, installation_id.length) + "X"
function setCurrentUser() { function setCurrentUser() {
lbryio.call('user', 'me').then((data) => { lbryio.call('user', 'me').then((data) => {

View file

@ -70,14 +70,14 @@ reducers[types.UPDATE_VERSION] = function(state, action) {
reducers[types.OPEN_MODAL] = function(state, action) { reducers[types.OPEN_MODAL] = function(state, action) {
return Object.assign({}, state, { return Object.assign({}, state, {
modal: action.data.modal, modal: action.data.modal,
extraContent: action.data.errorList modalExtraContent: action.data.extraContent
}) })
} }
reducers[types.CLOSE_MODAL] = function(state, action) { reducers[types.CLOSE_MODAL] = function(state, action) {
return Object.assign({}, state, { return Object.assign({}, state, {
modal: undefined, modal: undefined,
extraContent: undefined modalExtraContent: undefined
}) })
} }

View file

@ -180,9 +180,9 @@ export const selectUpgradeDownloadItem = createSelector(
(state) => state.downloadItem (state) => state.downloadItem
) )
export const selectError = createSelector( export const selectModalExtraContent = createSelector(
_selectState, _selectState,
(state) => state.error (state) => state.modalExtraContent
) )
export const selectDaemonReady = createSelector( export const selectDaemonReady = createSelector(

View file

@ -1,6 +1,6 @@
@import "../global"; @import "../global";
.modal-overlay { .modal-overlay, .error-modal-overlay {
position: fixed; position: fixed;
display: flex; display: flex;
justify-content: center; justify-content: center;