Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Conversation

@tanx
Copy link
Contributor

@tanx tanx commented Aug 7, 2018

@willpiers I took a look at the architecture and it turned out I had to refactor quite a bit to make this work. This probably wasn't a very good issue to get started with in the code base.

Closes #486

@tanx tanx requested a review from valentinewallace August 7, 2018 15:34
@tanx tanx mentioned this pull request Aug 7, 2018
Copy link
Contributor

@valentinewallace valentinewallace left a comment

Choose a reason for hiding this comment

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

very cool, learned a lot about electron haha.

nice refactor as well! i like the addition of the action class + the tests look great :)

It was hard for me to actually test the packaged app since i'm in the US which is the default, but I'm planning to set up a VPN soon which would enable me to test the locale detection more robustly. But if it's working for you in production, I'm good to merge! :)

expect(logger.error, 'was called with', /Detecting/, /Boom/);
});

it('should fall back to USD for unsupported fiat', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

very nice tests

const filter = event => {
if (!/^(lnd)|(unlock)|(log)|(open-url)[a-zA-Z_-]{0,20}$/.test(event)) {
if (
!/^(lnd)|(unlock)|(log)|(locale)|(open-url)[a-zA-Z_-]{0,20}$/.test(event)
Copy link
Contributor

Choose a reason for hiding this comment

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

is this a security measure?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. See #75

* @fileOverview a low level action to wrap electron's IPC renderer api.
*/

class IpcAction {
Copy link
Contributor

Choose a reason for hiding this comment

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

this is nice 👌

learned a lot about electron reading this code!

* Triggered the first time the app was started e.g. to set the
* local fiat currency only once.
*/
observe(store, 'firstStart', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

seems like we could get rid of this logic by following the pattern of WalletAction's init function instead (maybe trying to restore from AppStorage instead).

or alternately, simplify WalletAction's init function by putting wallet initialization in this trigger..

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 thought about that too...

seems like we could get rid of this logic by following the pattern of WalletAction's init function instead (maybe trying to restore from AppStorage instead).

Problem is we can't use the settings action inside wallet init, because setting already depends on wallet i.e. it's injected to fetch the exchange rate.

or alternately, simplify WalletAction's init function by putting wallet initialization in this trigger..

Not super happy about that either because we can't really unit test this routine. Trying to keep all testable logic in actions.

@tanx
Copy link
Contributor Author

tanx commented Aug 9, 2018

It was hard for me to actually test the packaged app since i'm in the US which is the default, but I'm planning to set up a VPN soon which would enable me to test the locale detection more robustly. But if it's working for you in production, I'm good to merge! :)

The detection isn't based on IP address so VPN won't help. You'd need to change your Language & Region OS settings to be in another Country. But the unit tests cover that for Germany and Japan so you don't have to :)

@tanx
Copy link
Contributor Author

tanx commented Aug 9, 2018

Merging. Thanks @willpiers for the initial PR. Turns out this was quite a refactoring. @valentinewallace thanks for the review.

@tanx tanx merged commit 8e97a93 into master Aug 9, 2018
@tanx tanx deleted the detect-locale-updated branch August 9, 2018 07:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants