Skip to content

Commit

Permalink
fix duplicated pinned clips
Browse files Browse the repository at this point in the history
  • Loading branch information
codokie committed Apr 1, 2024
1 parent 314c6e5 commit 40ca8c9
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,14 @@ class ClipboardHistoryManager(
}

fun onPinnedClipsAvailable(pinnedClips: List<ClipboardHistoryEntry>) {
historyEntries.addAll(pinnedClips)
sortHistoryEntries()
val added = historyEntries.addAll(pinnedClips.filterNot { pinnedClip ->
historyEntries.any { historyEntry ->
historyEntry.content == pinnedClip.content
}
})
if (added) {
sortHistoryEntries()
}
if (onHistoryChangeListener != null) {
pinnedClips.forEach {
onHistoryChangeListener?.onClipboardHistoryEntryAdded(historyEntries.indexOf(it))
Expand Down

0 comments on commit 40ca8c9

Please sign in to comment.