mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-17 16:47:01 +05:30
src: remove is_saved from LobstersPost and fix tests
Signed-off-by: Aditya Wasan <adityawasan55@gmail.com>
This commit is contained in:
parent
6b3b35d4df
commit
1251ae3bc0
4 changed files with 12 additions and 69 deletions
|
@ -45,14 +45,14 @@ class LobstersRepository @Inject constructor(private val lobstersDatabase: Lobst
|
|||
suspend fun addPost(post: LobstersPost) = withContext(Dispatchers.IO) {
|
||||
if (!savedPostsCache.containsKey(post.short_id)) {
|
||||
savedPostsCache.putIfAbsent(post.short_id, post)
|
||||
lobstersDatabase.postQueries.insertOrReplacePost(post.copy(is_saved = true))
|
||||
lobstersDatabase.postQueries.insertOrReplacePost(post)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun removePost(post: LobstersPost) = withContext(Dispatchers.IO) {
|
||||
if (savedPostsCache.containsKey(post.short_id)) {
|
||||
savedPostsCache.remove(post.short_id)
|
||||
lobstersDatabase.postQueries.removeSavedPost(post.short_id)
|
||||
lobstersDatabase.postQueries.deletePost(post.short_id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,7 +56,6 @@ val TEST_POST = LobstersPost(
|
|||
emptyList(),
|
||||
),
|
||||
listOf("openbsd", "linux", "containers", "hack the planet", "no thanks"),
|
||||
false,
|
||||
)
|
||||
|
||||
@Composable
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue