Skip to content

Commit

Permalink
New method for cleaning old entries added to avoid selector problems (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasstrba authored Aug 8, 2022
1 parent 749386d commit b4231de
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions DuckDuckGo/History/Model/HistoryCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,14 @@ final class HistoryCoordinator: HistoryCoordinating {
}
}

@objc private func cleanOldAndLoad(completionHandler: ((Error?) -> Void)? = nil) {
clean(until: .monthAgo, completionHandler: completionHandler)
var cleaningDate: Date { .monthAgo }

@objc private func cleanOld() {
clean(until: cleaningDate)
}

private func cleanOldAndLoad(completionHandler: ((Error?) -> Void)?) {
clean(until: cleaningDate, completionHandler: completionHandler)
}

private func clean(until date: Date,
Expand Down Expand Up @@ -310,7 +316,7 @@ final class HistoryCoordinator: HistoryCoordinating {
let timer = Timer(fireAt: .startOfDayTomorrow,
interval: .day,
target: self,
selector: #selector(cleanOldAndLoad),
selector: #selector(cleanOld),
userInfo: nil,
repeats: true)
RunLoop.main.add(timer, forMode: RunLoop.Mode.common)
Expand Down

0 comments on commit b4231de

Please sign in to comment.