Skip to content

Commit

Permalink
adjust some data caching parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
bwees committed Sep 13, 2024
1 parent 30039e7 commit 00cf6ab
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
4 changes: 1 addition & 3 deletions app/components/ui/IconPill.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ const IconPill: React.FC<Props> = ({text, icon, style}) => {
const theme = useAppStore((state) => state.theme);

return (
<View
onLayout={(layout) => console.log(layout.nativeEvent.layout.height)}

<View
style={[{
// backgroundColor: color,
borderColor: theme.pillBorder,
Expand Down
11 changes: 10 additions & 1 deletion app/components/ui/StopCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import useAppStore from "../../data/app_state";
import AmenityRow from "./AmenityRow";
import moment from "moment";
import { useStopEstimate } from "app/data/api_query";
import { useQueryClient } from "@tanstack/react-query";

interface Props {
stop: IStop
Expand All @@ -26,11 +27,19 @@ const StopCell: React.FC<Props> = ({ stop, route, direction, color, disabled, se
const setPoppedUpStopCallout = useAppStore((state) => state.setPoppedUpStopCallout);
const selectedRoute = useAppStore((state) => state.selectedRoute);
const theme = useAppStore((state) => state.theme);
const client = useQueryClient();

Check failure on line 30 in app/components/ui/StopCell.tsx

View workflow job for this annotation

GitHub Actions / tsc

'client' is declared but its value is never read.

const { data: stopEstimate, isLoading, isError } = useStopEstimate(route.key, direction.key, stop.stopCode);

useEffect(() => {
if (!stopEstimate || stopEstimate.routeDirectionTimes.length == 0) return
if (!stopEstimate) return;

// this is usually caused by out of date base data
// therefore refresh the base data
if (stopEstimate.routeDirectionTimes.length == 0) {
setStatus("Error loading estimates, try again later.");
return
}

const estimate = stopEstimate.routeDirectionTimes[0]!;

Expand Down
4 changes: 3 additions & 1 deletion app/data/api_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { getColorScheme } from "app/utils";
import moment from "moment";
import { GetBaseDataResponseSchema, GetNextDepartTimesResponseSchema, GetPatternPathsResponseSchema, GetStopEstimatesResponseSchema, GetStopSchedulesResponseSchema, GetTripPlanResponseSchema, GetVehiclesResponseSchema, IFoundLocation, IFoundStop, IGetBaseDataResponse, IGetNextDepartTimesResponse, IGetPatternPathsResponse, IGetStopEstimatesResponse, IGetStopSchedulesResponse, IGetVehiclesResponse, IMapRoute, IMapServiceInterruption, IPatternPoint, IVehicle, SearchSuggestion } from "utils/interfaces";

var hasInvalid = 0;

Check failure on line 8 in app/data/api_query.ts

View workflow job for this annotation

GitHub Actions / tsc

'hasInvalid' is declared but its value is never read.

export const useAuthToken = () => {
const query = useQuery({
Expand Down Expand Up @@ -112,7 +113,8 @@ export const useRoutes = () => {
return mergedRoutes;
},
enabled: patternPathsQuery.isSuccess && baseDataQuery.isSuccess,
staleTime: Infinity
staleTime: 2 * 3600 * 1000, // 2 hours
refetchInterval: 2 * 3600 * 1000, // 2 hours
});

return query;
Expand Down

0 comments on commit 00cf6ab

Please sign in to comment.