Skip to content

Commit

Permalink
Make the bookmark list distinct
Browse files Browse the repository at this point in the history
  • Loading branch information
io7m committed Nov 16, 2023
1 parent 6e710ba commit 63d1f46
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 24 deletions.
40 changes: 23 additions & 17 deletions README-CHANGES.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,35 @@
<c:change date="2023-07-03T00:00:00+00:00" summary="Fixed bug of bookmark not being deleted right after being added."/>
</c:changes>
</c:release>
<c:release date="2023-11-16T09:53:56+00:00" is-open="true" ticket-system="org.lyrasis.jira" version="2.5.0">
<c:changes>
<c:change date="2023-11-16T09:53:56+00:00" summary="API misuse could result in duplicate bookmarks appearing in lists.">
<c:tickets>
<c:ticket id="PP-727"/>
</c:tickets>
</c:change>
</c:changes>
</c:release>
<c:release date="2023-03-14T00:00:00+00:00" is-open="false" ticket-system="org.nypl.jira" version="1.0.4">
<c:changes>
<c:change date="2023-01-10T00:00:00+00:00" summary="Fixed book title not being displayed with dark background."/>
<c:change date="2023-02-13T00:00:00+00:00" summary="Added support for book previews."/>
</c:changes>
</c:release>
<c:release date="2023-11-03T00:00:00+00:00" is-open="false" ticket-system="org.nypl.jira" version="2.3.0">
<c:changes>
<c:change date="2023-11-03T00:00:00+00:00" summary="Fix some lifecycle issues.">
<c:tickets>
<c:ticket id="PP-676"/>
</c:tickets>
</c:change>
</c:changes>
</c:release>
<c:release date="2023-11-15T00:00:00+00:00" is-open="false" ticket-system="org.lyrasis.jira" version="2.4.0">
<c:changes>
<c:change date="2023-11-15T00:00:00+00:00" summary="Fix some more lifecycle issues."/>
</c:changes>
</c:release>
<c:release date="2022-08-13T00:00:00+00:00" is-open="false" ticket-system="org.nypl.jira" version="1.0.2">
<c:changes>
<c:change date="2022-05-03T00:00:00+00:00" summary="Update R2 libraries version"/>
Expand All @@ -38,23 +61,6 @@
<c:release date="2023-11-03T00:00:00+00:00" is-open="false" ticket-system="org.nypl.jira" version="2.1.1">
<c:changes/>
</c:release>
<c:release date="2023-11-03T00:00:00+00:00" is-open="false" ticket-system="org.nypl.jira" version="2.3.0">
<c:changes>
<c:change date="2023-11-03T00:00:00+00:00" summary="Fix some lifecycle issues.">
<c:tickets>
<c:ticket id="PP-676"/>
</c:tickets>
</c:change>
</c:changes>
</c:release>
<c:release date="2023-11-15T00:00:00+00:00" is-open="false" ticket-system="org.lyrasis.jira" version="2.4.0">
<c:changes>
<c:change date="2023-11-15T00:00:00+00:00" summary="Fix some more lifecycle issues."/>
</c:changes>
</c:release>
<c:release date="2023-11-15T11:45:26+00:00" is-open="true" ticket-system="org.lyrasis.jira" version="2.4.1">
<c:changes/>
</c:release>
</c:releases>
<c:ticket-systems>
<c:ticket-system default="true" id="org.lyrasis.jira" url="https://ebce-lyrasis.atlassian.net/browse/"/>
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ POM_SCM_CONNECTION=scm:git:git://github.com/ThePalaceProject/android-r2
POM_SCM_DEV_CONNECTION=scm:git:ssh://[email protected]/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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
},
Expand Down Expand Up @@ -458,15 +458,15 @@ internal class SR2Controller private constructor(
bookmark.copy(
isBeingDeleted = bookmark == apiCommand.bookmark,
)
}
}.distinct().toList()
this.publishEvent(
SR2BookmarkTryToDelete(
bookmark = apiCommand.bookmark,
onDeleteOperationFinished = { wasDeleted ->
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 ->
Expand All @@ -477,7 +477,7 @@ internal class SR2Controller private constructor(
bookmark.isBeingDeleted
},
)
}
}.distinct().toList()
this.publishEvent(SR2BookmarkFailedToBeDeleted)
}
},
Expand Down Expand Up @@ -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))
}
},
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 63d1f46

Please sign in to comment.