Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Account popup #135

Merged
merged 19 commits into from
Jun 16, 2017
Merged

Account popup #135

merged 19 commits into from
Jun 16, 2017

Conversation

whilei
Copy link
Contributor

@whilei whilei commented Jun 15, 2017

Not 100% sure if this architecture is sound or best way to do it... happy for any feedback.

A work in progress as I learn React and Redux.

Rel #127


Update:
I think it's pretty much to spec now, and seems functional in my own click-throughs.

@elaineo Note that I opted to use open instead of modal to allow the user to also outside-click/ESC to close the popup (modal requires clicking a certain button). And thanks a lot for your feedback and guidance along the way.

const AccountPopup = connect(
(state, ownProps) => {
const account = state.get('accountPopup', Immutable.fromJS());
const open = account === {};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you are fetching accountPopup from the global state, which isn't necessary. Since the ADD ETC button is in the account page, you can just pass the account in as a prop. eg:

<AccountPopup account={ownProps.account} />

(assuming that is what you are trying to do)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, looks like you are already doing that. You can also store popup state in a local state:

class AccountPopup extends React.Component {
constructor(props) {
    super(props);
    this.state = {
      popupstuff
    };
  }
    render() {
      <Dialog />
    } 
} 

Copy link
Contributor Author

@whilei whilei Jun 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see -- that's similar to how the docs had it, too. Was a little concerned about tangling this.state with Redux's state...

I was aiming to make a button/dialogue that would be reusable for an account's page (accounts/show.js) as well as from an account list item (accounts/account.js), without having to load the dialog code more than once.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, you mean just reuse the rendered component? like the ones in lib/elements/*.js?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oooo, I hadn't looked at elements... that looks along the lines of what I was thinking.
Realizing now maybe I don't need to worry so much about multiple-rendered DOM elements (ie <AccountPopup/> because of the whole Virtual DOM thing. It may not be any simpler/elegant anyways, and would avoid a global
hm, will do some more homework this eve

@elaineo
Copy link
Contributor

elaineo commented Jun 16, 2017

FYI, in components/accounts/show.js i added a button that calls showModal, which will set modal state to true.
https://github.com/ethereumproject/emerald-wallet/pull/143/files#diff-adf850d54e53e4e817b03502c40e4abd

@whilei whilei changed the title [WIP] Account popup Account popup Jun 16, 2017
@whilei whilei requested a review from splix June 16, 2017 18:12
@whilei
Copy link
Contributor Author

whilei commented Jun 16, 2017

Please check my "Minimal amount" for transfer on the popup... I just used

new Wei(21000000000); // Rough estimate tx gasprice; 21000 * 10^6

not sure if that's what it should be.

Copy link
Contributor

@elaineo elaineo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good ... the one part where you have inline comments might cause an error, because react doesn't know to interpret javascript comments unless they're in { ...}

Also my personal preference is to keep the ADD ETC button separate from the Dialog component, since the button is technically a part of the layout in which it appears, but no big deal 👍

style={styles.openButton} />
<Dialog
// title="Add Ether"
// actions={actions}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't this cause an error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i have no idea why i got away with that

const accounts = state.accounts.get('accounts');
const pos = accounts.findKey((acc) => acc.get('id') === ownProps.account.get('id'));
const rates = state.accounts.get('rates');
const gasPrice = new Wei(21000000000); // Rough estimate tx gasprice; 21000 * 10^6
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

current gasprice about 21,338 MWei (http://gastracker.io/)

src/lib/types.js Outdated
if (typeof (r) === 'undefined' || r === null) {
r = 0;
}
if (typeof decimals === 'undefined' || decimals === null) {
decimals = 5;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe make default decimals 2 for fiat

@whilei
Copy link
Contributor Author

whilei commented Jun 16, 2017

And duly noted on preferable component separation... I would do except I'm not exactly sure how right now, and would rather spend my time today tackling the next issue. Please feel very welcome to make the change anytime if you want

@whilei whilei merged commit b377223 into emeraldpay:master Jun 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants