mirror of
https://github.com/metabolist/metatext.git
synced 2024-11-25 17:50:59 +00:00
Cleanup
This commit is contained in:
parent
fa162fde77
commit
2c19d248ab
2 changed files with 5 additions and 2 deletions
|
@ -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) }
|
||||
|
|
|
@ -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]
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue