refactor: update camera settings route and improve error/loading messages in components by increasing swipe size
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||
import { OUTSIDE_CAM_BASE } from "../utils/config";
|
||||
import { CAM_BASE } from "../utils/config";
|
||||
import type { CameraBlackBoardOptions } from "../types/types";
|
||||
|
||||
const getBlackboardData = async () => {
|
||||
const response = await fetch(`${OUTSIDE_CAM_BASE}/api/blackboard`);
|
||||
const response = await fetch(`${CAM_BASE}/api/blackboard`);
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to fetch blackboard data");
|
||||
}
|
||||
@@ -11,7 +11,7 @@ const getBlackboardData = async () => {
|
||||
};
|
||||
|
||||
const viewBlackboardData = async (options: CameraBlackBoardOptions) => {
|
||||
const response = await fetch(`${OUTSIDE_CAM_BASE}/api/blackboard`, {
|
||||
const response = await fetch(`${CAM_BASE}/api/blackboard`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(options),
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||
import { toast } from "sonner";
|
||||
import { OUTSIDE_CAM_BASE } from "../utils/config";
|
||||
import { CAM_BASE } from "../utils/config";
|
||||
|
||||
const base_url = `${OUTSIDE_CAM_BASE}/api`;
|
||||
const base_url = `${CAM_BASE}/api`;
|
||||
console.log(base_url);
|
||||
|
||||
const fetchCameraSideConfig = async ({ queryKey }: { queryKey: string[] }) => {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { useRef, useCallback, useEffect } from "react";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { OUTSIDE_CAM_BASE } from "../utils/config";
|
||||
import { CAM_BASE } from "../utils/config";
|
||||
|
||||
const apiUrl = OUTSIDE_CAM_BASE;
|
||||
const apiUrl = CAM_BASE;
|
||||
|
||||
async function fetchSnapshot(cameraSide: string) {
|
||||
const response = await fetch(`${apiUrl}/${cameraSide}-preview`);
|
||||
async function fetchSnapshot() {
|
||||
const response = await fetch(`${apiUrl}/CameraA-preview`);
|
||||
if (!response.ok) {
|
||||
throw new Error("Cannot reach endpoint");
|
||||
}
|
||||
@@ -13,7 +13,7 @@ async function fetchSnapshot(cameraSide: string) {
|
||||
return await response.blob();
|
||||
}
|
||||
|
||||
export function useGetOverviewSnapshot(cameraSide: string) {
|
||||
export function useGetOverviewSnapshot() {
|
||||
const latestUrlRef = useRef<string | null>(null);
|
||||
const canvasRef = useRef<HTMLCanvasElement | null>(null);
|
||||
const imageRef = useRef<HTMLImageElement | null>(null);
|
||||
@@ -37,8 +37,8 @@ export function useGetOverviewSnapshot(cameraSide: string) {
|
||||
error,
|
||||
isPending,
|
||||
} = useQuery({
|
||||
queryKey: ["overviewSnapshot", cameraSide],
|
||||
queryFn: () => fetchSnapshot(cameraSide),
|
||||
queryKey: ["overviewSnapshot"],
|
||||
queryFn: () => fetchSnapshot(),
|
||||
refetchOnWindowFocus: false,
|
||||
refetchInterval: 250,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user