Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
For #11905 - Delete pocket story also when imageUrl changes
Browse files Browse the repository at this point in the history
This will allow updated imageUrls to be persisted and offered to clients.

(cherry picked from commit 5e6055b)

# Conflicts:
#	docs/changelog.md
  • Loading branch information
Mugurell authored and mergify[bot] committed Mar 25, 2022
1 parent c4546a1 commit f3aef8e
Show file tree
Hide file tree
Showing 4 changed files with 397 additions and 3 deletions.
4 changes: 3 additions & 1 deletion components/service/pocket/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ dependencies {

testImplementation Dependencies.kotlin_reflect

testImplementation Dependencies.androidx_arch_core_testing
testImplementation Dependencies.androidx_test_core
testImplementation Dependencies.androidx_test_junit
testImplementation Dependencies.testing_robolectric
testImplementation Dependencies.testing_coroutines
testImplementation Dependencies.testing_mockito
testImplementation Dependencies.testing_robolectric

testImplementation project(':support-test')
testImplementation project(':lib-fetch-httpurlconnection')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ internal interface PocketRecommendationsDao {
*/
@Transaction
suspend fun cleanOldAndInsertNewPocketStories(stories: List<PocketStoryEntity>) {
val newStoriesUrls = stories.map { it.url }
// If any url changed that story is obsolete and should be deleted.
val newStoriesUrls = stories.map { it.url to it.imageUrl }
val oldStoriesToDelete = getPocketStories()
.filterNot { it.url in newStoriesUrls }
.filterNot { newStoriesUrls.contains(it.url to it.imageUrl) }
delete(oldStoriesToDelete)

insertPocketStories(stories)
Expand Down
Loading

0 comments on commit f3aef8e

Please sign in to comment.