mirror of
https://github.com/trezor/trezor-wallet
synced 2024-11-24 01:08:27 +00:00
update Account page when location changed
This commit is contained in:
parent
9020ecc176
commit
f2a7c0c150
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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),
|
||||
};
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
@ -51,8 +48,7 @@ const mapDispatchToProps: MapDispatchToProps<Dispatch, OwnProps, DispatchProps>
|
||||
return {
|
||||
abstractAccountActions: bindActionCreators(AbstractAccountActions, dispatch),
|
||||
sendFormActions: bindActionCreators(SendFormActions, dispatch),
|
||||
initAccount: bindActionCreators(SendFormActions.init, dispatch),
|
||||
updateAccount: bindActionCreators(SendFormActions.update, dispatch),
|
||||
initAccount: bindActionCreators(SendFormActions.init, dispatch),
|
||||
disposeAccount: bindActionCreators(SendFormActions.dispose, dispatch),
|
||||
};
|
||||
}
|
||||
|
@ -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,
|
||||
@ -54,8 +51,7 @@ const mapDispatchToProps: MapDispatchToProps<Dispatch, OwnProps, DispatchProps>
|
||||
return {
|
||||
abstractAccountActions: bindActionCreators(AbstractAccountActions, dispatch),
|
||||
|
||||
initAccount: bindActionCreators(SummaryActions.init, dispatch),
|
||||
updateAccount: bindActionCreators(SummaryActions.update, dispatch),
|
||||
initAccount: bindActionCreators(SummaryActions.init, dispatch),
|
||||
disposeAccount: bindActionCreators(SummaryActions.dispose, dispatch),
|
||||
|
||||
onDetailsToggle: bindActionCreators(SummaryActions.onDetailsToggle, dispatch),
|
||||
|
Loading…
Reference in New Issue
Block a user