mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 04:44:37 +03:00
Make migration an asynchronous task (#4666)
* Add failed state and error to Job * Move migration code * Add websocket monitor * Make migrate a job managed task
This commit is contained in:
34
ui/v2.5/src/ConnectionMonitor.tsx
Normal file
34
ui/v2.5/src/ConnectionMonitor.tsx
Normal file
@@ -0,0 +1,34 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { getWSClient, useWSState } from "./core/StashService";
|
||||
import { useToast } from "./hooks/Toast";
|
||||
import { useIntl } from "react-intl";
|
||||
|
||||
export const ConnectionMonitor: React.FC = () => {
|
||||
const Toast = useToast();
|
||||
const intl = useIntl();
|
||||
|
||||
const { state } = useWSState(getWSClient());
|
||||
const [cachedState, setCacheState] = useState<typeof state>(state);
|
||||
|
||||
useEffect(() => {
|
||||
if (cachedState === "connecting" && state === "error") {
|
||||
Toast.error(
|
||||
intl.formatMessage({
|
||||
id: "connection_monitor.websocket_connection_failed",
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
if (state === "connected" && cachedState === "error") {
|
||||
Toast.success(
|
||||
intl.formatMessage({
|
||||
id: "connection_monitor.websocket_connection_reestablished",
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
setCacheState(state);
|
||||
}, [state, cachedState, Toast, intl]);
|
||||
|
||||
return null;
|
||||
};
|
||||
Reference in New Issue
Block a user