mirror of
https://github.com/Radarr/Radarr.git
synced 2026-03-29 18:15:37 -04:00
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
import React, { useEffect } from 'react';
|
|
import { useDispatch, useSelector } from 'react-redux';
|
|
import AppState from 'App/State/AppState';
|
|
import PageSidebarStatus from 'Components/Page/Sidebar/PageSidebarStatus';
|
|
import usePrevious from 'Helpers/Hooks/usePrevious';
|
|
import { fetchQueueStatus } from 'Store/Actions/queueActions';
|
|
import createQueueStatusSelector from './createQueueStatusSelector';
|
|
|
|
function QueueStatus() {
|
|
const dispatch = useDispatch();
|
|
const { isConnected, isReconnecting } = useSelector(
|
|
(state: AppState) => state.app
|
|
);
|
|
const { isPopulated, count, errors, warnings } = useSelector(
|
|
createQueueStatusSelector()
|
|
);
|
|
|
|
const wasReconnecting = usePrevious(isReconnecting);
|
|
|
|
useEffect(() => {
|
|
if (!isPopulated) {
|
|
dispatch(fetchQueueStatus());
|
|
}
|
|
}, [isPopulated, dispatch]);
|
|
|
|
useEffect(() => {
|
|
if (isConnected && wasReconnecting) {
|
|
dispatch(fetchQueueStatus());
|
|
}
|
|
}, [isConnected, wasReconnecting, dispatch]);
|
|
|
|
return (
|
|
<PageSidebarStatus count={count} errors={errors} warnings={warnings} />
|
|
);
|
|
}
|
|
|
|
export default QueueStatus;
|