src: remove is_saved from LobstersPost and fix tests

Signed-off-by: Aditya Wasan <adityawasan55@gmail.com>
This commit is contained in:
Aditya Wasan 2021-01-31 18:49:49 +05:30
parent 6b3b35d4df
commit 1251ae3bc0
No known key found for this signature in database
GPG key ID: 6D6DF3BF15DE79B5
4 changed files with 12 additions and 69 deletions

View file

@ -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)
}
}
}

View file

@ -56,7 +56,6 @@ val TEST_POST = LobstersPost(
emptyList(),
),
listOf("openbsd", "linux", "containers", "hack the planet", "no thanks"),
false,
)
@Composable