diff --git a/app/components/pages/Market.jsx b/app/components/pages/Market.jsx index 41cdac52f2..0cf12ee685 100644 --- a/app/components/pages/Market.jsx +++ b/app/components/pages/Market.jsx @@ -211,7 +211,7 @@ class Market extends React.Component { }, {}) } - let account = this.props.account + let account = this.props.account ? this.props.account.toJS() : null; let open_orders = this.props.open_orders; let orderbook = aggOrders(normalizeOrders(this.props.orderbook)); diff --git a/app/components/pages/Witnesses.jsx b/app/components/pages/Witnesses.jsx index 3c910da090..75719b6652 100644 --- a/app/components/pages/Witnesses.jsx +++ b/app/components/pages/Witnesses.jsx @@ -5,7 +5,7 @@ import links from 'app/utils/Links' import Icon from 'app/components/elements/Icon'; import transaction from 'app/redux/Transaction' import ByteBuffer from 'bytebuffer' -import {Set} from 'immutable' +import {Set, is} from 'immutable' import { translate } from 'app/Translator'; const Long = ByteBuffer.Long @@ -16,7 +16,7 @@ class Witnesses extends React.Component { // HTML properties // Redux connect properties - global: object.isRequired, + witnesses: object.isRequired, accountWitnessVote: func.isRequired, username: string, witness_votes: object, @@ -36,20 +36,20 @@ class Witnesses extends React.Component { } } + shouldComponentUpdate(np, ns) { + return ( + !is(np.witness_votes, this.props.witness_votes) || + np.witnesses !== this.props.witnesses || + np.username !== this.props.username || + ns.customUsername !== this.state.customUsername + ); + } + render() { - const {props: {global, witness_votes}, state: {customUsername}, accountWitnessVote, onWitnessChange} = this - const sorted_witnesses = global.getIn(['witnesses']) + const {props: {witness_votes}, state: {customUsername}, accountWitnessVote, onWitnessChange} = this + const sorted_witnesses = this.props.witnesses .sort((a, b) => Long.fromString(String(b.get('votes'))).subtract(Long.fromString(String(a.get('votes'))).toString())); - const header = -
-
- -
-
- -
-
const up = ; let witness_vote_count = 30 let rank = 1 @@ -164,7 +164,7 @@ module.exports = { const current_account = current_user && state.global.getIn(['accounts', username]) const witness_votes = current_account && Set(current_account.get('witness_votes')) return { - global: state.global, + witnesses: state.global.get('witnesses'), username, witness_votes, }; diff --git a/app/redux/MarketSaga.js b/app/redux/MarketSaga.js index a7178d4472..576c6c52b0 100644 --- a/app/redux/MarketSaga.js +++ b/app/redux/MarketSaga.js @@ -1,9 +1,10 @@ -import {takeLatest, takeEvery} from 'redux-saga'; -import {call, put, select} from 'redux-saga/effects'; +import {takeLatest} from 'redux-saga'; +import {call, put} from 'redux-saga/effects'; import Apis from 'shared/api_client/ApiInstances'; import MarketReducer from './MarketReducer'; -import constants from './constants'; -import {fromJS, Map} from 'immutable' +import g from 'app/redux/GlobalReducer' +// import constants from './constants'; +import {fromJS} from 'immutable' export const marketWatches = [watchLocationChange, watchUserLogin, watchMarketUpdate]; @@ -68,9 +69,12 @@ export function* fetchOpenOrders(set_user_action) { const state = yield call([db_api, db_api.exec], 'get_open_orders', [username]); yield put(MarketReducer.actions.receiveOpenOrders(state)); - const [account] = yield call(Apis.db_api, 'get_accounts', [username]) - yield put(MarketReducer.actions.receiveAccount({ account })) - + let [account] = yield call(Apis.db_api, 'get_accounts', [username]) + if(account) { + account = fromJS(account) + yield put(MarketReducer.actions.receiveAccount({ account })) + yield put(g.actions.receiveAccount({ account })) + } } catch (error) { console.error('~~ Saga fetchOpenOrders error ~~>', error); yield put({type: 'global/STEEM_API_ERROR', error: error.message});