Skip to content

Commit

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

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

0 comments on commit 0992bbc

Please sign in to comment.