Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
parity
fether
Commits
e4c69874
Unverified
Commit
e4c69874
authored
Nov 23, 2018
by
Amaury Martiny
Committed by
GitHub
Nov 23, 2018
Browse files
Merge pull request #263 from paritytech/ac-fix-2s
WithHealth: Wait 2s before showing not synced (fix #262)
parents
9089bc9b
e93d3715
Pipeline
#26252
passed with stages
in 13 minutes and 48 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
packages/fether-react/src/RequireHealthOverlay/RequireHealthOverlay.js
View file @
e4c69874
...
...
@@ -32,48 +32,29 @@ class RequireHealthOverlay extends Component {
};
state
=
{
visible
:
false
// false | true | id of the timeout that will make the overlay visible
// We want to display the overlay after 2s of problematic health. Syncing
// to new blocks from the top of the chain takes 1s and we don't want to
// display the overlay in that case.
visible
:
false
};
componentDidMount
()
{
// Initial render check. Display overlay immediately if problematic health.
if
(
!
statusMatches
(
this
.
props
.
health
.
status
,
this
.
props
.
require
))
{
this
.
setState
({
visible
:
true
});
}
this
.
updateVisibility
();
}
componentDidUpdate
()
{
if
(
statusMatches
(
this
.
props
.
health
.
status
,
this
.
props
.
require
))
{
// If there is an ongoing timeout to make the overlay visible, clear it
if
(
typeof
this
.
state
.
visible
===
'
number
'
)
{
clearTimeout
(
this
.
state
.
visible
);
}
this
.
updateVisibility
();
}
updateVisibility
=
()
=>
{
if
(
statusMatches
(
this
.
props
.
health
.
status
,
this
.
props
.
require
))
{
if
(
this
.
state
.
visible
!==
false
)
{
this
.
setState
({
visible
:
false
});
}
}
else
{
// Bad node health
// Display the overlay after 2s (if there is no ongoing timeout)
if
(
this
.
state
.
visible
===
false
)
{
this
.
setState
({
visible
:
setTimeout
(()
=>
{
this
.
setState
({
visible
:
true
});
},
2000
)
});
this
.
setState
({
visible
:
true
});
}
}
}
componentWillUnmount
()
{
if
(
typeof
this
.
state
.
visible
===
'
number
'
)
{
clearTimeout
(
this
.
state
.
visible
);
}
}
render
()
{
const
{
visible
}
=
this
.
state
;
const
{
fullscreen
}
=
this
.
props
;
...
...
packages/fether-react/src/utils/withHealth.js
View file @
e4c69874
...
...
@@ -4,9 +4,10 @@
// SPDX-License-Identifier: BSD-3-Clause
import
BigNumber
from
'
bignumber.js
'
;
import
{
combineLatest
,
Observable
,
fromEvent
,
merge
}
from
'
rxjs
'
;
import
{
combineLatest
,
Observable
,
of
,
fromEvent
,
merge
}
from
'
rxjs
'
;
import
{
compose
,
mapPropsStream
}
from
'
recompose
'
;
import
{
delay
,
distinctUntilChanged
,
filter
,
map
,
...
...
@@ -107,7 +108,12 @@ const rpcs$ = isApiConnected$.pipe(
startingBlock
}
};
})
}),
// Emit "not synced" only if we haven't been synced for over 2 seconds,
// as syncing to new blocks from the top of the chain usually takes ~1s.
// syncStatus$() is distinctUntilChanged, so {isSync: false} will never
// be fired twice in a row.
switchMap
(
sync
=>
sync
.
isSync
?
of
(
sync
)
:
of
(
sync
).
pipe
(
delay
(
2000
)))
),
peerCount$
().
pipe
(
withoutLoading
())
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment