diff --git a/.env.sample b/.env.sample index 9c08b70..a8b82aa 100644 --- a/.env.sample +++ b/.env.sample @@ -1,3 +1,3 @@ VITE_KAKAO_MAP_API_KEY= -VITE_API_BASE_URL= +VITE_API_BASE_URL=https://whatthebus.duckdns.org VITE_API_KEY= \ No newline at end of file diff --git a/src/App.tsx b/src/App.tsx index 61c4850..85f60e5 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -39,9 +39,10 @@ function App() { const langId = useId(); const [language, setLanguage] = useState(() => { try { - const stored = typeof window !== "undefined" && window.localStorage - ? localStorage.getItem("wtb:lang") - : null; + const stored = + typeof window !== "undefined" && window.localStorage + ? localStorage.getItem("wtb:lang") + : null; return stored === "en" ? "en" : "ko"; } catch { return "ko"; @@ -67,10 +68,7 @@ function App() { return ( - + { - // Only show toast once to avoid spamming on refetch failures - if (!errorShownRef.current) { - toast({ - title: "버스 위치 조회 오류", - description: message, - variant: "destructive", - }); - errorShownRef.current = true; - // Reset after 30 seconds to allow showing error again if it persists - setTimeout(() => { - errorShownRef.current = false; - }, 30000); - } - }, [toast]); + const handleBusLocationError = useCallback( + (message: string) => { + // Only show toast once to avoid spamming on refetch failures + if (!errorShownRef.current) { + toast({ + title: "버스 위치 조회 오류", + description: message, + variant: "destructive", + }); + errorShownRef.current = true; + // Reset after 30 seconds to allow showing error again if it persists + setTimeout(() => { + errorShownRef.current = false; + }, 30000); + } + }, + [toast] + ); const { data: buses = [] } = useBusLocations(handleBusLocationError); const handleBusNumberSelect = useBusSelection(buses, setBubbleStop); @@ -167,8 +168,8 @@ function AppContent({ /> ) : null} - diff --git a/src/api/bus.ts b/src/api/bus.ts index 87c1ccb..9b198d5 100644 --- a/src/api/bus.ts +++ b/src/api/bus.ts @@ -4,9 +4,7 @@ import { apiGet } from "../lib/api"; import { API_ENDPOINTS } from "../lib/endpoints"; import { handleApiError } from "../lib/error"; -export const useBusLocations = ( - onError?: (message: string) => void -) => { +export const useBusLocations = (onError?: (message: string) => void) => { return useQuery({ queryKey: ["busLocations"], queryFn: async () => { @@ -21,7 +19,7 @@ export const useBusLocations = ( return []; } }, - refetchInterval: 5000, + refetchInterval: 7000, refetchIntervalInBackground: true, retry: 2, }); diff --git a/src/components/Bubble.tsx b/src/components/Bubble.tsx index adbdfd3..4d10bac 100644 --- a/src/components/Bubble.tsx +++ b/src/components/Bubble.tsx @@ -57,7 +57,7 @@ export default function Bubble({ stop, onClose }: Props) { document.body.appendChild(el); const rawName = String(stop.name); - + // Check if it's a bus key (starts with "bus.") let displayName: string; if (rawName.startsWith("bus.")) { @@ -67,15 +67,18 @@ export default function Bubble({ stop, onClose }: Props) { // It's a bus stop name const translationKey = `busStop.${rawName}`; const translatedName = t(translationKey); - + // If translation key is returned as-is, use the raw name instead - const displayBaseName = translatedName === translationKey ? rawName : translatedName; + const displayBaseName = + translatedName === translationKey + ? rawName + : translatedName; displayName = displayBaseName; if (DISPLAY_NAME_MAP[rawName]) { - const directionKey = DISPLAY_NAME_MAP[rawName].includes( - "죽전역" - ) + const directionKey = DISPLAY_NAME_MAP[ + rawName + ].includes("죽전역") ? "direction.toJukjeon" : "direction.toDKU"; displayName = `${displayBaseName} (${t(directionKey)})`; diff --git a/src/components/SettingsPanel.tsx b/src/components/SettingsPanel.tsx index 91dd319..a5994b1 100644 --- a/src/components/SettingsPanel.tsx +++ b/src/components/SettingsPanel.tsx @@ -83,7 +83,9 @@ const SettingsPanel: React.FC = ({