From 63d1f4615db95f8b5314a69e087a9105cd16a536 Mon Sep 17 00:00:00 2001 From: Mark Raynsford Date: Thu, 16 Nov 2023 09:54:43 +0000 Subject: [PATCH] Make the bookmark list distinct Affects: https://ebce-lyrasis.atlassian.net/browse/PP-727 --- README-CHANGES.xml | 40 +++++++++++-------- gradle.properties | 2 +- .../r2/vanilla/internal/SR2Controller.kt | 12 +++--- 3 files changed, 30 insertions(+), 24 deletions(-) diff --git a/README-CHANGES.xml b/README-CHANGES.xml index db2259a..89e8d2d 100644 --- a/README-CHANGES.xml +++ b/README-CHANGES.xml @@ -10,12 +10,35 @@ + + + + + + + + + + + + + + + + + + + + + + + @@ -38,23 +61,6 @@ - - - - - - - - - - - - - - - - - diff --git a/gradle.properties b/gradle.properties index 4fe97b3..23877e3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ POM_SCM_CONNECTION=scm:git:git://github.com/ThePalaceProject/android-r2 POM_SCM_DEV_CONNECTION=scm:git:ssh://git@github.com/ThePalaceProject/android-r2 POM_SCM_URL=http://github.com/ThePalaceProject/android-r2 POM_URL=http://github.com/ThePalaceProject/android-r2 -VERSION_NAME=2.4.1-SNAPSHOT +VERSION_NAME=2.5.0-SNAPSHOT VERSION_PREVIOUS=2.4.0 android.useAndroidX=true diff --git a/org.librarysimplified.r2.vanilla/src/main/java/org/librarysimplified/r2/vanilla/internal/SR2Controller.kt b/org.librarysimplified.r2.vanilla/src/main/java/org/librarysimplified/r2/vanilla/internal/SR2Controller.kt index 1f636b4..57bebab 100644 --- a/org.librarysimplified.r2.vanilla/src/main/java/org/librarysimplified/r2/vanilla/internal/SR2Controller.kt +++ b/org.librarysimplified.r2.vanilla/src/main/java/org/librarysimplified/r2/vanilla/internal/SR2Controller.kt @@ -326,7 +326,7 @@ internal class SR2Controller private constructor( val newBookmarks = this.bookmarks.toMutableList() newBookmarks.removeAll { bookmark -> bookmark.type == LAST_READ } newBookmarks.add(createdBookmark) - this.bookmarks = newBookmarks.toList() + this.bookmarks = newBookmarks.distinct().toList() this.publishEvent(SR2BookmarkCreated(createdBookmark)) } }, @@ -458,7 +458,7 @@ internal class SR2Controller private constructor( bookmark.copy( isBeingDeleted = bookmark == apiCommand.bookmark, ) - } + }.distinct().toList() this.publishEvent( SR2BookmarkTryToDelete( bookmark = apiCommand.bookmark, @@ -466,7 +466,7 @@ internal class SR2Controller private constructor( if (wasDeleted) { val newBookmarks = this.bookmarks.toMutableList() newBookmarks.remove(apiCommand.bookmark) - this.bookmarks = newBookmarks.toList() + this.bookmarks = newBookmarks.distinct().toList() this.publishEvent(SR2BookmarkDeleted(apiCommand.bookmark)) } else { this.bookmarks = this.bookmarks.map { bookmark -> @@ -477,7 +477,7 @@ internal class SR2Controller private constructor( bookmark.isBeingDeleted }, ) - } + }.distinct().toList() this.publishEvent(SR2BookmarkFailedToBeDeleted) } }, @@ -511,7 +511,7 @@ internal class SR2Controller private constructor( if (createdBookmark != null) { val newBookmarks = this.bookmarks.toMutableList() newBookmarks.add(createdBookmark) - this.bookmarks = newBookmarks.toList() + this.bookmarks = newBookmarks.distinct().toList() this.publishEvent(SR2BookmarkCreated(createdBookmark)) } }, @@ -546,7 +546,7 @@ internal class SR2Controller private constructor( ): ListenableFuture<*> { val newBookmarks = this.bookmarks.toMutableList() newBookmarks.addAll(apiCommand.bookmarks) - this.bookmarks = newBookmarks.toList() + this.bookmarks = newBookmarks.distinct().toList() this.publishEvent(SR2BookmarksLoaded) return Futures.immediateFuture(Unit) }