Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@
"complexity": {
"noVoid": "error"
},

"correctness": {
"useExhaustiveDependencies": "off",
"useExhaustiveDependencies": "info",
"noUndeclaredVariables": "error",
"useJsxKeyInIterable": "error"
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/alerts/AlertsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function TtcAlertList() {
(_event: SelectTabEvent, data: SelectTabData) => {
setEnabledTab(data.value);
},
[enabledTab]
[]
);
const currentDate = new Date().toISOString().split("T")[0];
// get saturday's date
Expand Down
4 changes: 2 additions & 2 deletions src/components/alerts/bsky-alerts/AllBskyAlerts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const AllBskyAlerts = () => {
(_event: SelectTabEvent, data: SelectTabData) => {
setEnabledTab(data.value as string);
},
[enabledTab]
[]
);

const lastSkeetTime = useMemo(() => {
Expand Down Expand Up @@ -110,7 +110,7 @@ export const AllBskyAlerts = () => {
setTimeframe(option);
}
},
[timeframe]
[]
);

return (
Expand Down
17 changes: 10 additions & 7 deletions src/components/alerts/subway-closures/SubwayClosures.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useQuery } from "@tanstack/react-query";
import { useMemo } from "react";
import { useCallback, useMemo } from "react";

import {
fetchSubwayClosure,
Expand All @@ -20,19 +20,22 @@ export const SubwayClosures = ({ startDate }: { startDate: string }) => {
return "Subway Closures";
}, [startDate, currentDate]);

const getClosuresByDateMatch = (match: boolean) =>
subwayClosureQuery.data?.filter(
(closure) => (closure.last_shown === currentDate) === match
) ?? [];
const getClosuresByDateMatch = useCallback(
(match: boolean) =>
subwayClosureQuery.data?.filter(
(closure) => (closure.last_shown === currentDate) === match
) ?? [],
[subwayClosureQuery.data, currentDate]
);

const listedSubwayClosures = useMemo(
() => getClosuresByDateMatch(true),
[subwayClosureQuery, currentDate]
[getClosuresByDateMatch]
);

const unlistedSubwayClosures = useMemo(
() => getClosuresByDateMatch(false),
[subwayClosureQuery, currentDate]
[getClosuresByDateMatch]
);

if (!subwayClosureQuery.isFetched) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/bookmarks/Bookmark.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default function Bookmark() {

const clearAllBookmarks = useCallback(() => {
dispatch(clearStopBookmarks());
}, []);
}, [dispatch]);

return (
<article className="bookmark-container">
Expand Down
2 changes: 1 addition & 1 deletion src/components/bookmarks/BookmarkCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function BookmarkCard(props: { id: number }) {

const checkBookmarkStatus = useCallback(() => {
dispatch(removeStopBookmark(props.id));
}, [stopBookmarks.ids]);
}, [dispatch, props.id]);

const item = stopBookmarks.entities[id];

Expand Down
2 changes: 1 addition & 1 deletion src/components/countdown/CountdownSec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function CountdownSec(props: {
}
// Cleanup
return () => clearTimeout(timer);
}, [sec]);
}, [epochTime, sec, props.epochTime]);
return (
<div className={style["countdown-sec"]}>
{(sec < 180 || props.index === 0) && (
Expand Down
2 changes: 1 addition & 1 deletion src/components/display/VehicleLocation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default function VehicleLocation(props: {
const center = fromLonLat([data.vehicle?.lon, data.vehicle?.lat]);
setView({ center, zoom: 16 });
}
}, []);
}, [props.data?.Error, data.vehicle]);

if (error) {
return (
Expand Down
15 changes: 9 additions & 6 deletions src/components/etaCard/EtaCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
DialogTrigger,
} from "@fluentui/react-components";
import { Dismiss12Filled, Edit12Filled } from "@fluentui/react-icons";
import { useCallback } from "react";
import { useCallback, useMemo } from "react";
import { useTranslation } from "react-i18next";
import { Link } from "react-router";

Expand All @@ -32,7 +32,9 @@ export function EtaCard(props: {
enabled?: string[];
direction?: string;
}) {
const uniqueLines = [...new Set(props.lines)];
const uniqueLines = useMemo(() => {
return [...new Set(props.lines)];
}, [props.lines]);
const directionArray = props.direction?.split(", ") ?? [];
return (
<li
Expand Down Expand Up @@ -123,8 +125,9 @@ function FavouriteEditor(props: {
enabled?: string[];
onDelete?: () => void;
}) {
const uniqueLines = [...new Set(props.lines)];

const uniqueLines = useMemo(() => {
return [...new Set(props.lines)];
}, [props.lines]);
const { t } = useTranslation();

const dispatch = useAppDispatch();
Expand Down Expand Up @@ -171,7 +174,7 @@ function FavouriteEditor(props: {
}
}
},
[uniqueLines, props.enabled]
[uniqueLines, props.enabled, dispatch, props.id]
);

return (
Expand Down Expand Up @@ -207,7 +210,7 @@ function LineCheckbox(props: {
}) {
const handleClick = useCallback(() => {
props.onChangeFunction(props.line);
}, [props.enabled]);
}, [props.onChangeFunction, props.line]);
return (
<Checkbox
key={props.id + props.line}
Expand Down
2 changes: 1 addition & 1 deletion src/components/fetch/FetchLineStop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function LineStopPredictionInfo(props: {

const fetchPredictionClick = useCallback(() => {
setLastUpdatedAt(Date.now());
}, [lastUpdatedAt]);
}, []);

if (data) {
if (data.Error) {
Expand Down
4 changes: 2 additions & 2 deletions src/components/fetch/FetchRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ function RouteInfo(props: { line: number }): JSX.Element {

const handleFetchBusClick = useCallback(() => {
setLastUpdatedAt(Date.now());
}, [lastUpdatedAt]);
}, []);

const handleDirClick = useCallback(
(_event: SelectTabEvent, data: SelectTabData) => setEnabledDir(data.value),
[enabledDir]
[]
);

if (ttcRouteResponse.data) {
Expand Down
4 changes: 2 additions & 2 deletions src/components/fetch/FetchSubwayRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ function RouteInfo(props: { line: number }): JSX.Element {
return () => {
controller.abort();
};
}, [lastUpdatedAt, ttcSubwayLineResponse.data]);
}, [ttcSubwayLineResponse.data, dispatch, lineNum]);

const handleFetchBusClick = useCallback(() => {
setLastUpdatedAt(Date.now());
}, [lastUpdatedAt]);
}, []);

if (ttcSubwayLineResponse.data) {
const data = ttcSubwayLineResponse.data;
Expand Down
6 changes: 3 additions & 3 deletions src/components/fetch/FetchSubwayStop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ function SubwayStopPredictionInfo(props: {

const fetchPredictions = useCallback(() => {
setLastUpdatedAt(Date.now());
}, [lastUpdatedAt]);
}, []);

const fetchPredictionClick = useCallback(() => {
fetchPredictions();
}, []);
}, [fetchPredictions]);

const stationInfo = subwayDbSelectors.selectById(
store.getState().subwayDb,
Expand All @@ -58,7 +58,7 @@ function SubwayStopPredictionInfo(props: {
);
});
},
[data?.nextTrains]
[data?.nextTrains, t]
);

if (!data) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/fetch/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ export const atprotoTtcAlerts = queryOptions<FeedViewPost[]>({
});

export const getYrtStops = queryOptions<
{ stopId: string; stopPublicId: string }[]
{ stopId: string; stopPublicId: string; name: string }[]
>({
queryKey: ["yrt-stops"],
queryFn: async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/nav/BaseBarComponents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function BaseBarComponents({ width }: { width: number }) {
default:
return fluentStyle.smallRoundNavButton;
}
}, [width]);
}, [width, fluentStyle]);

const baseBarComponents = navItems.map((item) => {
return (
Expand Down
6 changes: 3 additions & 3 deletions src/components/nearby/Nearby.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ export default function Nearby() {
setIsLoadingLocation(false);
});
}
}, []);
}, [handleRefresh]);

useEffect(() => {
if (locationMode) {
handleGeolocation();
}
}, []);
}, [locationMode, handleGeolocation]);

const locationModeChange = useCallback(
(ev: {
Expand All @@ -103,7 +103,7 @@ export default function Nearby() {
})
);
},
[setLocationMode]
[dispatch]
);

return (
Expand Down
2 changes: 1 addition & 1 deletion src/components/nearby/NearbyList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default function NearbyList(props: {
),
};
});
}, [stopsList, props.coordinate]);
}, [subwayStops, props.coordinate]);

const busAndSubwayStops = useMemo(() => {
if (!stopsList.length) {
Expand Down
4 changes: 2 additions & 2 deletions src/components/nearby/NearbyStopCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default function NearbyStopCard({ stop }: { stop: StopWithDistance }) {
return templist.sort((a, b) => a.epochTime - b.epochTime);
}
return [];
}, [getStopPredictionsResponse.data]);
}, [stop.type, getStopPredictionsResponse.data]);

const lines = useMemo(() => {
if (stop.type === "ttc-subway") {
Expand All @@ -67,7 +67,7 @@ export default function NearbyStopCard({ stop }: { stop: StopWithDistance }) {
return undefined;
}
return stop.directions;
}, [stop, getStopPredictionsResponse.data]);
}, [stop]);

return (
<EtaCard
Expand Down
4 changes: 1 addition & 3 deletions src/components/rawDisplay/RawDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,13 @@ export default function RawDisplay(props: {
const fluentStyle = fluentStyles();
const { t } = useTranslation();

const settings = settingsSelectors.selectAll(store.getState().settings);

const devModeValue = settingsSelectors.selectById(
store.getState().settings,
"devMode"
);
const isInDevMode = useMemo(
() => (devModeValue ? devModeValue.value === "true" : false),
[settings]
[devModeValue]
);

const rawDisplay = (
Expand Down
8 changes: 4 additions & 4 deletions src/components/settings/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function Settings() {
(_: FormEvent<HTMLDivElement>, data: { value?: string }) => {
i18n.changeLanguage(data.value);
},
[]
[i18n.changeLanguage]
);

const handleUnifiedEtaChange = useCallback(
Expand All @@ -68,7 +68,7 @@ export function Settings() {
})
);
},
[setUnifiedEta]
[dispatch]
);

const devModeChange = useCallback(
Expand All @@ -85,7 +85,7 @@ export function Settings() {
})
);
},
[setDevMode]
[dispatch]
);

// Temp. search box
Expand All @@ -105,7 +105,7 @@ export function Settings() {
navigate(`../yrt/stops/${stopInput}`);
}
}
}, [stopInput]);
}, [stopInput, navigate]);

return (
<main className={style["settings-page"]}>
Expand Down
2 changes: 1 addition & 1 deletion src/routes/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default function Home() {
})
);
},
[enabledTab]
[dispatch]
);
return (
<main className="home-page">
Expand Down
4 changes: 2 additions & 2 deletions src/routes/RelativeVehiclePosition.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function RelativeVehiclePosition() {

const onRefreshClick = useCallback(() => {
setLastUpdatedAt(Date.now());
}, [lastUpdatedAt]);
}, []);

return (
<main className={styles["relative-vehicle-position"]}>
Expand All @@ -55,7 +55,7 @@ function RefreshButton({ onClick }: { onClick: () => void }) {

const useOnClick = useCallback(() => {
onClick();
}, []);
}, [onClick]);

return (
<Button onClick={useOnClick} icon={<ArrowClockwise24Regular />}>
Expand Down
2 changes: 1 addition & 1 deletion src/routes/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default function SearchElement() {
if (lineInput !== "") {
navigate(`lines/${lineInput}`);
}
}, [lineInput]);
}, [lineInput, navigate]);

return (
<div className="search-form">
Expand Down