early return if status page public and not published

This commit is contained in:
Alex Holliday
2025-02-08 08:05:42 -08:00
parent 1fabf918c3
commit 2f1f2d1a3f
3 changed files with 12 additions and 6 deletions

View File

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

View File

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

View File

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