fix: implement reciter caching with timestamp validation #1517
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
This PR fixes
Description
This PR introduces a caching mechanism for reciter data to improve performance and reduce unnecessary network calls. The changes include:
_timestampBox
) to track the last update time of reciter data.ReciteImpl
to ensure data is refreshed only when outdated.getLastUpdatedTimestamp
method to retrieve the cache timestamp.reciteLocalDataSourceProvider
to include the new_timestampBox
.reciteRemoteDataSourceProvider
to use a directDioModule
instance for simplicity._getRemoteReciters
for cleaner code flow.kQuranCacheBoxName
andkQuranReciterRetentionTime
) for better maintainability.These changes ensure that reciter data is cached locally and refreshed only when necessary, improving the app's performance and user experience.
Tests
🧪 Use case 1
💬 Description:
Launch the app and verify that reciter data is fetched from the cache if it was updated within the last 30 days. If the cache is outdated, ensure the data is fetched from the remote API and the cache is updated.
📷 Screenshots or GIFs (if applicable):
N/A
Checklist: