Skip to content
This repository has been archived by the owner on Apr 11, 2022. It is now read-only.

refactor(context): Split ApiContext into Api & SystemContext #120

Merged
merged 4 commits into from
Jan 30, 2020

Conversation

amaury1093
Copy link
Contributor

needed for paritytech/substrate-light-ui#743

@@ -0,0 +1,152 @@
// Copyright 2018-2020 @paritytech/substrate-light-ui authors & contributors
Copy link
Contributor

Choose a reason for hiding this comment

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

🎉

@@ -24,7 +23,7 @@ export function ContextGate({
<AccountsContextProvider>
<TxQueueContextProvider>
<ApiContextProvider provider={new WsProvider(ARCHIVE_NODE_ENDPOINT)}>
<StakingContextProvider>{children}</StakingContextProvider>
<>{children}</>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<>{children}</>
{children}

Copy link
Contributor Author

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.

ah, i guess that makes sense....

const [allBalances, setAllBalances] = useState();
const [allStaking, setAllStaking] = useState();

useEffect(() => {
if (isReady) {
if (isApiReady) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I find it weird that we have to do this everywhere, since none of these should load in the first place before the isApiReady is set to true in the ContextGate.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

since none of these should load in the first place before the isApiReady is set to true in the ContextGate

Hmm, if we put this in ui-components and expose this package to npm, then I don't think we should assume that the end-user will user this component inside a ContextGate when isApiReady is set to true. Just to be sure, I'd leave this check here.

In light-ui, if we use internal components that are behind a Gate, then yeah we can remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Edit: but also, as we talked before, a better way would simply only expose pure/stateless components in ui-components

@amaury1093 amaury1093 merged commit e076925 into master Jan 30, 2020
@amaury1093 amaury1093 deleted the am-new-context branch January 30, 2020 13:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants