Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,22 @@ function cacheKey(userId: string, trailName?: string): string {
/** Persist fetched reports to AsyncStorage for offline / cold-start access. */
async function writeCachedReports(
reports: TrailConditionReport[],
userId: string,
trailName?: string,
opts: { userId: string; trailName?: string },
) {
try {
await AsyncStorage.setItem(cacheKey(userId, trailName), JSON.stringify(reports));
await AsyncStorage.setItem(cacheKey(opts.userId, opts.trailName), JSON.stringify(reports));
} catch {
// Best-effort — swallow write errors silently
}
}

/** Read previously-cached reports from AsyncStorage. */
async function readCachedReports(
userId: string,
trailName?: string,
): Promise<TrailConditionReport[] | undefined> {
async function readCachedReports(opts: {
userId: string;
trailName?: string;
}): Promise<TrailConditionReport[] | undefined> {
try {
const raw = await AsyncStorage.getItem(cacheKey(userId, trailName));
const raw = await AsyncStorage.getItem(cacheKey(opts.userId, opts.trailName));
Comment on lines 19 to +36
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The options-object type is duplicated with two different inline shapes (single-line vs multi-line). Consider introducing a shared type alias (e.g., "type CacheReportsOpts = { userId: string; trailName?: string }") and using it for both functions to keep the signatures consistent and reduce future drift.

Copilot uses AI. Check for mistakes.
if (raw) return JSON.parse(raw) as TrailConditionReport[];
} catch {
// Corrupt or missing cache — ignore
Expand Down Expand Up @@ -78,7 +77,7 @@ export function useTrailConditionReports(trailName?: string) {
useEffect(() => {
let cancelled = false;
setCachedReports(undefined);
readCachedReports(currentUserId, trailName).then((reports) => {
readCachedReports({ userId: currentUserId, trailName }).then((reports) => {
if (!cancelled) setCachedReports(reports);
});
return () => {
Expand Down Expand Up @@ -106,7 +105,7 @@ export function useTrailConditionReports(trailName?: string) {
useEffect(() => {
if (query.data && query.data !== prevDataRef.current && query.isFetched) {
prevDataRef.current = query.data;
writeCachedReports(query.data, currentUserId, trailName);
writeCachedReports(query.data, { userId: currentUserId, trailName });
}
}, [query.data, query.isFetched, currentUserId, trailName]);

Expand Down
24 changes: 23 additions & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"useMaxParams": {
"level": "error",
"options": {
"max": 3
"max": 2
}
}
},
Expand All @@ -46,6 +46,28 @@
}
}
},
"overrides": [
{
"includes": [
"apps/expo/atoms/atomWith*.ts",
"apps/expo/features/weather/atoms/locationsAtoms.ts",
"packages/api/src/routes/admin/index.ts",
"packages/api/src/services/r2-bucket.ts",
"packages/api/src/services/etl/processCatalogEtl.ts",
"packages/api/test/guides.test.ts",
"packages/api/test/setup.ts",
"apps/expo/utils/weight.ts",
"packages/api/src/utils/weight.ts"
],
"linter": {
"rules": {
"complexity": {
"useMaxParams": "off"
}
}
}
}
],
Comment on lines +49 to +70
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Biome override selectors use the key "include" (not "includes"). With "includes", these overrides likely won’t apply, so the lint rule won’t be disabled for the intended files and CI may fail. Rename "includes" to "include" (and keep the array value as-is).

Copilot uses AI. Check for mistakes.
"css": {
"parser": {
"cssModules": false,
Expand Down
Loading