diff --git a/Client/src/Pages/DistributedUptime/Details/Hooks/useSubscribeToDetails.jsx b/Client/src/Pages/DistributedUptime/Details/Hooks/useSubscribeToDetails.jsx index 30c5d3ed6..9ee7fa873 100644 --- a/Client/src/Pages/DistributedUptime/Details/Hooks/useSubscribeToDetails.jsx +++ b/Client/src/Pages/DistributedUptime/Details/Hooks/useSubscribeToDetails.jsx @@ -45,7 +45,7 @@ const getRandomDevice = () => { model: randomModel, }; }; -const useSubscribeToDetails = ({ monitorId, dateRange }) => { +const useSubscribeToDetails = ({ monitorId, isPublic, isPublished, dateRange }) => { const [isLoading, setIsLoading] = useState(true); const [connectionStatus, setConnectionStatus] = useState(undefined); const [retryCount, setRetryCount] = useState(0); @@ -58,10 +58,15 @@ const useSubscribeToDetails = ({ monitorId, dateRange }) => { const prevDateRangeRef = useRef(dateRange); useEffect(() => { + if (typeof monitorId === "undefined") { + return; + } + // If this page is public and not published, don't subscribe to details + if (isPublic && isPublished === false) { + return; + } + try { - if (typeof monitorId === "undefined") { - return; - } const cleanup = networkService.subscribeToDistributedUptimeDetails({ authToken, monitorId, diff --git a/Client/src/Pages/DistributedUptime/Status/Hooks/useStatusPageFetchByUrl.jsx b/Client/src/Pages/DistributedUptime/Status/Hooks/useStatusPageFetchByUrl.jsx index 973e157c7..583fed69d 100644 --- a/Client/src/Pages/DistributedUptime/Status/Hooks/useStatusPageFetchByUrl.jsx +++ b/Client/src/Pages/DistributedUptime/Status/Hooks/useStatusPageFetchByUrl.jsx @@ -8,6 +8,7 @@ const useStatusPageFetchByUrl = ({ url }) => { const [networkError, setNetworkError] = useState(false); const [statusPage, setStatusPage] = useState(undefined); const [monitorId, setMonitorId] = useState(undefined); + const [isPublished, setIsPublished] = useState(false); const { authToken } = useSelector((state) => state.auth); useEffect(() => { const fetchStatusPageByUrl = async () => { @@ -17,6 +18,7 @@ const useStatusPageFetchByUrl = ({ url }) => { const statusPage = response.data.data; setStatusPage(statusPage); setMonitorId(statusPage?.monitors[0]); + setIsPublished(statusPage?.isPublished); } catch (error) { setNetworkError(true); createToast({ @@ -29,7 +31,7 @@ const useStatusPageFetchByUrl = ({ url }) => { fetchStatusPageByUrl(); }, [authToken, url]); - return [isLoading, networkError, statusPage, monitorId]; + return [isLoading, networkError, statusPage, monitorId, isPublished]; }; export { useStatusPageFetchByUrl }; diff --git a/Server/controllers/distributedUptimeController.js b/Server/controllers/distributedUptimeController.js index bef6662d3..1313adf82 100644 --- a/Server/controllers/distributedUptimeController.js +++ b/Server/controllers/distributedUptimeController.js @@ -1,7 +1,6 @@ import { handleError } from "./controllerUtils.js"; import Monitor from "../db/models/Monitor.js"; import DistributedUptimeCheck from "../db/models/DistributedUptimeCheck.js"; - const SERVICE_NAME = "DistributedUptimeQueueController"; class DistributedUptimeController {