Browse Source
568: Minor fixes improving UX of taker shutdown r=klochowicz a=klochowicz
- reduce log level of heartbeat message
- improve the toast message to clearly state possible action
Co-authored-by: Mariusz Klochowicz <mariusz@klochowicz.com>
new-http-api
bors[bot]
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
6 additions and
5 deletions
daemon/src/connection.rs
daemon/src/taker.rs
taker-frontend/src/App.tsx
taker-frontend/src/components/BackendMonitor.tsx
@ -135,7 +135,7 @@ impl Actor {
match msg {
wire ::MakerToTaker ::Heartbeat = > {
tracing ::info ! ( "got the heartbeat ") ;
tracing ::trace ! ( "received a heartbeat message from maker ") ;
self . connected_state
. as_mut ( )
. expect ( "wire messages only to arrive in connected state" )
@ -304,7 +304,7 @@ async fn main() -> Result<()> {
loop {
maker_online_status_feed_receiver . changed ( ) . await . unwrap ( ) ;
if maker_online_status_feed_receiver . borrow ( ) . clone ( ) = = ConnectionStatus ::Offline {
tracing ::info ! ( "Maker is offline. Shutting down the taker " ) ;
tracing ::info ! ( "Lost connection to maker, shutting down. Please restart the daemon to reconnect " ) ;
rocket ::Shutdown ::notify ( shutdown_handle ) ;
return ;
}
@ -45,7 +45,7 @@ async function postCfdOrderRequest(payload: CfdOrderRequestPayload) {
export const App = ( ) = > {
const toast = useToast ( ) ;
useBackendMonitor ( toast , 5000 ) ; // 5s timeout
useBackendMonitor ( toast , 5000 , "Please start the taker again to reconnect..." ) ; // 5s timeout
const {
lastMessage ,
@ -13,7 +13,8 @@ async function fetchWithTimeout(resource: any, timeout: number) {
// Check for backend's presence by sending a request to '/alive' endpoint.
// When the backend's not there, the request is likely to timeout, triggering a
// persistent toast notification that goes away when the daemon is back online.
export function useBackendMonitor ( toast : any , timeout_ms : number ) : void {
// `description` is a user-facing string describing problem/possible action.
export function useBackendMonitor ( toast : any , timeout_ms : number , description : string ) : void {
const toastIdRef = useRef ( ) ;
const checkForBackend : ( ) = > void = async ( ) = > {
@ -31,7 +32,7 @@ export function useBackendMonitor(toast: any, timeout_ms: number): void {
if ( ! toastIdRef . current ) {
toastIdRef . current = toast ( {
title : "Connection Error" ,
description : "Daemon process is not running" ,
description ,
status : "error" ,
position : "top" ,
duration : timeout_ms * 100000 , // we don't want this to be closed