Add setting for saving recents (fixes #14)

This commit is contained in:
Arkadiusz Fal
2021-12-01 12:22:19 +01:00
parent e61d1dfe2e
commit 06f7391ad9
5 changed files with 19 additions and 2 deletions

View File

@@ -3,7 +3,7 @@ import Foundation
final class RecentsModel: ObservableObject {
@Default(.recentlyOpened) var items
@Default(.saveRecents) var saveRecents
func clear() {
items = []
}
@@ -13,6 +13,14 @@ final class RecentsModel: ObservableObject {
}
func add(_ item: RecentItem) {
if !saveRecents {
clear()
if item.type != .channel {
return
}
}
if let index = items.firstIndex(where: { $0.id == item.id }) {
items.remove(at: index)
}