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

frontend: improve routing and introduce device switch #145

Merged
merged 1 commit into from Oct 28, 2018

Conversation

benma
Copy link
Contributor

@benma benma commented Oct 27, 2018

No description provided.

@benma benma force-pushed the cleanroutes branch 2 times, most recently from 6f39642 to c8f9176 Compare October 27, 2018 15:57
@benma benma merged commit 68f5fde into BitBoxSwiss:master Oct 28, 2018
}
}
time.Sleep(time.Second)
}
}

// Start listens for inserted/removed devices forever. Run this in a goroutine.
Copy link
Contributor

Choose a reason for hiding this comment

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

Run this in a goroutine.

Why? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Forgot to adjust the comment (was the same comment before refactor). Thanks! #150

});
if (!accountsInitialized) {
console.log('app.jsx route /'); // eslint-disable-line no-console
route('/', true);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it this why my accounts are no longer directly activated when I use the software-based keystore? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, that is because they are activated in device.jsx after unlock. Similar should be done in the software based one, or move this to a more generic place.

Btw. this particular lines I restored later, but adjusted to only apply when you are in /accounts/ (otherwise it would override othe redirects, e.g. to the inserted device, in a race).

path="/device/:deviceID"
deviceIDs={deviceIDs} />
<Device
key={devices}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need a key property here? 🤔 And this might no longer be valid/possible after preactjs/preact#1248.

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 picked apart multiple commits and this belonged to a different one afaik. Anyway, it carries over here:

https://github.com/digitalbitbox/bitbox-wallet-app/blob/75ae7661a2afa7882bc4e6fd9bb25ddf7303b9f5/frontends/web/src/app.jsx#L167

Needed to that the component remounts with different keys, to trigger the componentDidMount().

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Or at least add a comment why the key properties are needed there. This is very subtle and uncommon (as far as I can judge) and it's shortcuts like this that make our code so fragile.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can do. After doing the research on resetting components, using the key seems to be a normal solution, but noted.

Didn't use componentWillReceiveProps because it's use seems discouraged:

https://reactjs.org/docs/react-component.html#unsafe_componentwillreceiveprops

Copy link
Contributor

Choose a reason for hiding this comment

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

You can also use https://reactjs.org/docs/react-component.html#componentdidupdate, if you prefer. And I don't know to what degree Preact will follow such deprecations.

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