1
0
mirror of https://github.com/trezor/trezor-wallet synced 2024-11-24 09:18:09 +00:00

update Account page when location changed

This commit is contained in:
Szymon Lesisz 2018-05-09 11:14:44 +02:00
parent 9020ecc176
commit f2a7c0c150
8 changed files with 10 additions and 68 deletions

View File

@ -48,7 +48,7 @@ export const init = (): ThunkAction => {
}
}
export const update = (): ThunkAction => {
export const update = (initAccountAction: () => ThunkAction): ThunkAction => {
return (dispatch: Dispatch, getState: GetState): void => {
const {
abstractAccount,
@ -57,7 +57,7 @@ export const update = (): ThunkAction => {
const isLocationChanged: boolean = router.location.pathname !== abstractAccount.location;
if (isLocationChanged) {
dispatch( init() );
return;
initAccountAction();
}
}
}

View File

@ -39,21 +39,6 @@ export const init = (): ThunkAction => {
}
}
export const update = (): ThunkAction => {
return (dispatch: Dispatch, getState: GetState): void => {
const {
abstractAccount,
router
} = getState();
const isLocationChanged: boolean = router.location.pathname !== abstractAccount.location;
if (isLocationChanged) {
dispatch( init() );
}
}
}
export const dispose = (): Action => {
return {
type: RECEIVE.DISPOSE
@ -119,7 +104,6 @@ export const showAddress = (address_n: Array<number>): AsyncAction => {
export default {
init,
update,
dispose,
showAddress,
showUnverifiedAddress

View File

@ -211,21 +211,6 @@ export const init = (): ThunkAction => {
}
}
export const update = (): ThunkAction => {
return (dispatch: Dispatch, getState: GetState): void => {
const {
abstractAccount,
router
} = getState();
const isLocationChanged: boolean = router.location.pathname !== abstractAccount.location;
if (isLocationChanged) {
dispatch( init() );
return;
}
}
}
export const dispose = (): Action => {
return {
type: SEND.DISPOSE
@ -890,7 +875,6 @@ export const onSend = (): AsyncAction => {
export default {
init,
update,
dispose,
toggleAdvanced,

View File

@ -36,22 +36,6 @@ export const init = (): ThunkAction => {
}
}
export const update = (): ThunkAction => {
return (dispatch: Dispatch, getState: GetState): void => {
const {
abstractAccount,
router
} = getState();
const isLocationChanged: boolean = router.location.pathname !== abstractAccount.location;
if (isLocationChanged) {
dispatch( init() );
return;
}
}
}
export const dispose = (): Action => {
return {
type: SUMMARY.DISPOSE

View File

@ -58,7 +58,7 @@ const _render = (props: Props, state: AccountState): React$Element<string> => {
let address = `${account.address.substring(0, 20)}...`;
let className = 'address hidden';
let button = (
<button disabled={ !discovery.completed } onClick={ event => props.showAddress(account.addressPath) }>
<button disabled={ device.connected && !discovery.completed } onClick={ event => props.showAddress(account.addressPath) }>
<span>Show full address</span>
</button>
);
@ -126,7 +126,6 @@ const mapDispatchToProps: MapDispatchToProps<Dispatch, OwnProps, DispatchProps>
return {
abstractAccountActions: bindActionCreators(AbstractAccountActions, dispatch),
initAccount: bindActionCreators(ReceiveActions.init, dispatch),
updateAccount: bindActionCreators(ReceiveActions.update, dispatch),
disposeAccount: bindActionCreators(ReceiveActions.dispose, dispatch),
showAddress: bindActionCreators(ReceiveActions.showAddress, dispatch),
};

View File

@ -8,7 +8,7 @@ import { findDevice } from '../../../utils/reducerUtils';
// import * as AbstractAccountActions from '../../actions/AbstractAccountActions';
import { default as AbstractAccountActions } from '../../../actions/AbstractAccountActions';
import type { State, TrezorDevice } from '../../../flowtype';
import type { State, TrezorDevice, Action, ThunkAction } from '../../../flowtype';
import type { Account } from '../../../reducers/AccountsReducer';
import type { Discovery } from '../../../reducers/DiscoveryReducer';
@ -21,9 +21,8 @@ export type StateProps = {
export type DispatchProps = {
abstractAccountActions: typeof AbstractAccountActions,
initAccount: typeof AbstractAccountActions.init,
updateAccount: typeof AbstractAccountActions.update,
disposeAccount: typeof AbstractAccountActions.dispose,
initAccount: () => ThunkAction,
disposeAccount: () => Action,
}
export type Props = StateProps & DispatchProps;
@ -50,8 +49,8 @@ export default class AbstractAccount<P> extends Component<Props & P, AccountStat
}
componentWillReceiveProps(props: Props & P) {
this.props.abstractAccountActions.update();
this.props.updateAccount();
this.props.abstractAccountActions.update( this.props.initAccount );
const currentState = props.abstractAccount;

View File

@ -25,9 +25,6 @@ type StateProps = BaseStateProps & {
}
type DispatchProps = BaseDispatchProps & {
initAccount: typeof SendFormActions.init,
updateAccount: typeof SendFormActions.update,
disposeAccount: typeof SendFormActions.dispose,
sendFormActions: typeof SendFormActions
}
@ -52,7 +49,6 @@ const mapDispatchToProps: MapDispatchToProps<Dispatch, OwnProps, DispatchProps>
abstractAccountActions: bindActionCreators(AbstractAccountActions, dispatch),
sendFormActions: bindActionCreators(SendFormActions, dispatch),
initAccount: bindActionCreators(SendFormActions.init, dispatch),
updateAccount: bindActionCreators(SendFormActions.update, dispatch),
disposeAccount: bindActionCreators(SendFormActions.dispose, dispatch),
};
}

View File

@ -25,9 +25,6 @@ type StateProps = BaseStateProps & {
}
type DispatchProps = BaseDispatchProps & {
initAccount: typeof SummaryActions.init,
updateAccount: typeof SummaryActions.update,
disposeAccount: typeof SummaryActions.dispose,
onDetailsToggle: typeof SummaryActions.onDetailsToggle,
addToken: typeof TokenActions.add,
loadTokens: typeof TokenActions.load,
@ -55,7 +52,6 @@ const mapDispatchToProps: MapDispatchToProps<Dispatch, OwnProps, DispatchProps>
abstractAccountActions: bindActionCreators(AbstractAccountActions, dispatch),
initAccount: bindActionCreators(SummaryActions.init, dispatch),
updateAccount: bindActionCreators(SummaryActions.update, dispatch),
disposeAccount: bindActionCreators(SummaryActions.dispose, dispatch),
onDetailsToggle: bindActionCreators(SummaryActions.onDetailsToggle, dispatch),