Skip to content

Commit

Permalink
Ensure history size cannot grow beyond settings
Browse files Browse the repository at this point in the history
  • Loading branch information
p0deje committed Jul 31, 2024
1 parent b31daac commit f45c2ca
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Maccy/Observables/History.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ class History {

@MainActor
func add(_ item: HistoryItem) {
while items.filter(\.isUnpinned).count >= Defaults[.size] {
delete(items.last(where: \.isUnpinned))
}

if let existingHistoryItem = findSimilarItem(item) {
if isModified(item) == nil {
item.contents = existingHistoryItem.contents
Expand Down

0 comments on commit f45c2ca

Please sign in to comment.