You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] [Bug] useTaskFeed serves stale MMKV-cached tasks indefinitely — cached data is never revalidated on mount if the store is non-empty #150
The offline task feed cache is an explicit shipped feature. But the cache has no TTL and no revalidation trigger: if the store has tasks from a previous session, useTaskFeed serves them forever without ever calling the API again, even on a fresh app start with a working internet connection. New tasks added by the backend, status changes (open → closed), and reward amount updates are invisible until the user manually pulls to refresh.
Problem / What
src/hooks/useTaskFeed.ts:
useEffect(()=>{if(tasksRef.current.length===0){voidloadTasks(1);// only fetches if the store is empty}elseif(hasLocation){lastFetchLocationRef.current={lat: latasnumber,lng: lngasnumber};}// eslint-disable-next-line react-hooks/exhaustive-deps},[]);
If tasks.length > 0 (warm cache from a prior session), the mount effect skips the fetch entirely. There is no lastFetchedAt timestamp on taskStore and no revalidation logic.
The fix: add a tasksLastFetchedAt timestamp (ISO string) to taskStore via partializeTaskState (already exists) and set it in setTasks. In the mount effect, also trigger a background fetch when tasksLastFetchedAt is older than a configurable TASK_FEED_STALE_MS (e.g., 5 minutes). The background fetch should update the store silently — no loading skeleton during revalidation.
Key Challenges
The background revalidation must not overwrite selectedTask if the user is mid-navigation to a task detail.
TASK_FEED_STALE_MS should be a named constant, configurable in tests via a Jest module mock.
The sanitizePersistedTaskState function already runs on rehydration — it must pass tasksLastFetchedAt through.
useTaskFeed.test.ts and useTaskFeedRefetch.test.tsx must be extended to cover the stale-cache revalidation path.
Acceptance Criteria
taskStore gains a tasksLastFetchedAt field, persisted to MMKV.
useTaskFeed triggers a background fetch on mount when tasksLastFetchedAt is older than TASK_FEED_STALE_MS (5 min default), even if the store has tasks.
The background fetch does not show a loading skeleton.
selectedTask is not clobbered during background revalidation.
Tests: (a) warm cache within TTL → no fetch, (b) warm cache past TTL → background fetch, (c) selectedTask preserved after revalidation.
I’d like to work on this issue because it addresses an important area of the project and presents a great opportunity to make a meaningful contribution. I’m particularly interested in delivering a solution that is reliable, maintainable, and aligned with the project’s existing architecture and development standards.
I have experience working across software development, including backend and frontend development, APIs, databases, testing, DevOps, and blockchain-based applications. I’m comfortable understanding existing codebases, identifying the root cause of issues, implementing clean and scalable solutions, and writing thorough tests to prevent regressions.
My approach would be to first understand the existing implementation and project conventions, then develop the solution in a focused and incremental way. I’ll ensure the changes are well-tested, documented where necessary, and do not introduce unnecessary complexity or break existing functionality. I’m also committed to clear communication, responding to review feedback, and delivering a polished contribution that provides real value to the project.
Activity
devprom6 commentedon Aug 28, 2026
I’d like to work on this issue because it addresses an important area of the project and presents a great opportunity to make a meaningful contribution. I’m particularly interested in delivering a solution that is reliable, maintainable, and aligned with the project’s existing architecture and development standards.
I have experience working across software development, including backend and frontend development, APIs, databases, testing, DevOps, and blockchain-based applications. I’m comfortable understanding existing codebases, identifying the root cause of issues, implementing clean and scalable solutions, and writing thorough tests to prevent regressions.
My approach would be to first understand the existing implementation and project conventions, then develop the solution in a focused and incremental way. I’ll ensure the changes are well-tested, documented where necessary, and do not introduce unnecessary complexity or break existing functionality. I’m also committed to clear communication, responding to review feedback, and delivering a polished contribution that provides real value to the project.
grantfox-oss commentedon Aug 28, 2026
🦊 GrantFox — @devprom6 has been assigned to this issue as part of the Third Campaign campaign!
Next steps:
Closes #150)Good luck! Track your progress on GrantFox.
grantfox-oss commentedon Aug 28, 2026
🎉 This issue has been marked as completed on GrantFox as part of the Third Campaign campaign!
@devprom6's PR #151 was approved and merged by @cybermax4200.
🏆 @devprom6: You earned 35 FoxPoints for this contribution! Your current tier: Explorer (522 total points). Track your full progress on GrantFox.
👏 Great work, @devprom6! Keep contributing to ecotask-network.