mirror of
https://github.com/bluewave-labs/Checkmate.git
synced 2026-01-21 09:09:43 -06:00
early return if status page public and not published
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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 };
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user