-
-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
offline caching in home page #56
offline caching in home page #56
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @krishnachaitanya0107 . I have reviewed the files. Please make the required changes
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.flow | ||
import javax.inject.Inject | ||
|
||
const val POPULAR_ANIME="PopularAnime" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tags are already made in an enum class. If you want to save them to the database, use enum classes ordinal.
enum class HOME_TYPES(value: Int) {
POPULAR_ANIME(1),
RECENT_RELEASE(2)
....// and so on.
}
Also, to use the values we can just use HOME_TYPES.POPULAR_ANIME.ordinal or something like this.
@@ -23,6 +28,9 @@ class HomeDefaultRepo @Inject constructor( | |||
//TODO: Add local data first. (caching purpose) | |||
return flow { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here it should be fetching the animes from the local database only first and then if there is no data in cache, then we would be making the network request.
@@ -44,9 +58,14 @@ class HomeDefaultRepo @Inject constructor( | |||
* @returns: Flow<ResultWrapper<*>> | |||
* */ | |||
suspend fun parsePopularMovies(): Flow<ResultWrapper<*>> { | |||
//TODO: Add local data first. (caching purpose) | |||
return flow { | |||
val response = remoteRepo.getPopularMovies() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
@@ -56,9 +75,14 @@ class HomeDefaultRepo @Inject constructor( | |||
* @returns: Flow<ResultWrapper<*>> | |||
* */ | |||
suspend fun parseNewSeasons(): Flow<ResultWrapper<*>> { | |||
//TODO: Add local data first. (caching purpose) | |||
return flow { | |||
val response = remoteRepo.getNewSeasons() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
@justdvnsh i implemented the changes , please have a look and let me know if anything can be changed . one thing i wish to mention - I had to move utils/Hometypes from app module to utils module because i was facing a weird 'circular dependency between the following tasks' issue . |
@krishnachaitanya0107 Hi, can you resolve the merge conflicts and also, can you please provide a working video of your feature. Thanks |
Hey , resolved the merge conflicts . About the working video , there isn't any difference that i can show in the screen recording because this feature doesn't have any ui related changes . I actually used logs to see whether data is coming from room database while testing . |
@justdvnsh , please do let me know if you want any more changes in the code . I will be happy to implement them . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Thank your for your contributions.
Thank you @justdvnsh for going through my code , It's amazing to know that my contributions are helping out . |
@krishnachaitanya0107 Offline cache has been added, but it has disrupted the flow of favorites. See the favorites tab. It will show you all the cached items. We don't want that. I am making a new issue, you can take that up if you want. The solution is pretty simple. You just need to create a separate database for the cache rather than the usual database. |
Oops , Really sorry @justdvnsh i did not mean to mess up that flow 😅 . Ok i will take up the new issue . It would be great if you could guide me a bit on this . |
No description provided.