mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-17 23:47:02 +05:30
Set liked flag on first load
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
parent
1021604889
commit
0336af0624
1 changed files with 2 additions and 0 deletions
|
@ -62,6 +62,8 @@ class LobstersViewModel @ViewModelInject constructor(
|
|||
private fun getMorePostsInternal(firstLoad: Boolean) {
|
||||
viewModelScope.launch(coroutineExceptionHandler) {
|
||||
val newPosts = lobstersApi.getHottestPosts(apiPage)
|
||||
.map { it.apply { if (savedPostsDao.isLiked(shortId)) isLiked = true } }
|
||||
.toList()
|
||||
if (firstLoad) {
|
||||
_posts.value = newPosts
|
||||
postsDao.deleteAllPosts()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue