fix: CachedImage Animated.Value, SWR cache invalidation, background task timeout (#620 #621 #622)#709
Merged
Conversation
rinafcode#621 - CachedImage: move Animated.Value to useRef so the reference is stable across re-renders; fade-in animation now plays once on load. rinafcode#620 - SWR cache: add invalidateByPattern(RegExp) to cache.ts, define MUTATION_INVALIDATION_MAP in apiCacheConfig.ts, and wire the axios response interceptor to call invalidateByPattern after successful POST/PUT/PATCH/DELETE requests. rinafcode#622 - backgroundTaskScheduler: add runWithTimeout wrapping task execution in Promise.race with a 25-second timeout, logging the event on expiry. SyncService.runBackgroundSync delegates to runWithTimeout and checkpoints isSyncing=false on timeout. Tests: src/__tests__/issues/fixes_620_621_622.test.ts
|
@BashMan11 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
|
Thank you for contributing to the project. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes three bugs assigned to me in one atomic commit.
Closes #621 — CachedImage Animated.Value in render body
File:
src/components/ui/CachedImage.tsxAnimatedfrom react-nativeconst opacity = useRef(new Animated.Value(0)).current— reference is now stable across re-renderstransition={250}and replaced with an explicitAnimated.timingfade-in that fires once ononLoadingCompleteExpoImageinAnimated.Viewdriven by the stable opacity refCloses #620 — SWR cache does not invalidate after POST/PUT mutations
Files:
src/services/api/cache.ts,src/config/apiCacheConfig.ts,src/services/api/axios.config.tsinvalidateByPattern(pattern: RegExp)tocache.ts— iterates memory store and persistent layersrc/config/apiCacheConfig.tswithMUTATION_INVALIDATION_MAPmapping URL patterns + HTTP methods → invalidation RegExps (courses, users, lessons)invalidateByPatternsynchronously before returning the responseCloses #622 — backgroundTaskScheduler tasks unbounded (iOS 30-second limit)
Files:
src/utils/backgroundTaskScheduler.ts,src/services/syncService.tstimeoutPromise(ms)helper andrunWithTimeout(taskFn, taskName, timeoutMs=25000)that wraps execution inPromise.racewarnwith task name and elapsed ms, returns{ timedOut: true, taskDurationMs }enqueueLowPriorityTasknow accepts an optionalnameparameter and routes throughrunWithTimeoutSyncService.runBackgroundSync()— callsbackgroundScheduler.runWithTimeoutand checkpointsisSyncing=falseon timeout so the next run can resume cleanlyTests
src/__tests__/issues/fixes_620_621_622.test.tsObject.isconfirms opacity ref is identical across 5 re-rendersinvalidateByPatterncall; count returned correctlytimedOut=truefires at exactly 25 000 ms