Browse Source

Improve user-facing string if taker daemon shuts down

Make the error toast suggest the next reasonable action in case of such event.
new-http-api
Mariusz Klochowicz 3 years ago
parent
commit
ef27eff999
No known key found for this signature in database GPG Key ID: 470C865699C8D4D
  1. 2
      daemon/src/taker.rs
  2. 2
      taker-frontend/src/App.tsx
  3. 5
      taker-frontend/src/components/BackendMonitor.tsx

2
daemon/src/taker.rs

@ -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;
}

2
taker-frontend/src/App.tsx

@ -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,

5
taker-frontend/src/components/BackendMonitor.tsx

@ -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

Loading…
Cancel
Save