This commit is contained in:
Justin Mazzocchi 2021-01-17 14:52:49 -08:00
parent fa162fde77
commit 2c19d248ab
No known key found for this signature in database
GPG key ID: E223E6937AAFB01C
2 changed files with 5 additions and 2 deletions

View file

@ -27,7 +27,7 @@ public final class AddIdentityViewModel: ObservableObject {
self.instanceURLService = instanceURLService
let url = $urlFieldText
.debounce(for: 0.5, scheduler: DispatchQueue.global())
.debounce(for: .seconds(Self.textFieldDebounceInterval), scheduler: DispatchQueue.global())
.removeDuplicates()
.flatMap {
instanceURLService.url(text: $0).publisher
@ -86,6 +86,7 @@ public extension AddIdentityViewModel {
}
private extension AddIdentityViewModel {
private static let textFieldDebounceInterval: TimeInterval = 0.5
func addIdentity(kind: AllIdentitiesService.IdentityCreation) {
instanceURLService.url(text: urlFieldText).publisher
.map { ($0, kind) }

View file

@ -49,7 +49,7 @@ public final class CollectionItemsViewModel: ObservableObject {
identification.appPreferences.positionBehavior(markerTimeline: markerTimeline) == .rememberPosition
lastReadId.compactMap { $0 }
.removeDuplicates()
.debounce(for: 0.5, scheduler: DispatchQueue.global())
.debounce(for: .seconds(Self.lastReadIdDebounceInterval), scheduler: DispatchQueue.global())
.flatMap { identification.service.setLastReadId($0, forMarker: markerTimeline) }
.sink { _ in } receiveValue: { _ in }
.store(in: &cancellables)
@ -283,6 +283,8 @@ extension CollectionItemsViewModel: CollectionViewModel {
}
private extension CollectionItemsViewModel {
private static let lastReadIdDebounceInterval: TimeInterval = 0.5
var lastUpdateWasContextParentOnly: Bool {
collectionService is ContextService && lastUpdate.items.map(\.count) == [0, 1, 0]
}