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
|
self.instanceURLService = instanceURLService
|
||||||
|
|
||||||
let url = $urlFieldText
|
let url = $urlFieldText
|
||||||
.debounce(for: 0.5, scheduler: DispatchQueue.global())
|
.debounce(for: .seconds(Self.textFieldDebounceInterval), scheduler: DispatchQueue.global())
|
||||||
.removeDuplicates()
|
.removeDuplicates()
|
||||||
.flatMap {
|
.flatMap {
|
||||||
instanceURLService.url(text: $0).publisher
|
instanceURLService.url(text: $0).publisher
|
||||||
|
@ -86,6 +86,7 @@ public extension AddIdentityViewModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
private extension AddIdentityViewModel {
|
private extension AddIdentityViewModel {
|
||||||
|
private static let textFieldDebounceInterval: TimeInterval = 0.5
|
||||||
func addIdentity(kind: AllIdentitiesService.IdentityCreation) {
|
func addIdentity(kind: AllIdentitiesService.IdentityCreation) {
|
||||||
instanceURLService.url(text: urlFieldText).publisher
|
instanceURLService.url(text: urlFieldText).publisher
|
||||||
.map { ($0, kind) }
|
.map { ($0, kind) }
|
||||||
|
|
|
@ -49,7 +49,7 @@ public final class CollectionItemsViewModel: ObservableObject {
|
||||||
identification.appPreferences.positionBehavior(markerTimeline: markerTimeline) == .rememberPosition
|
identification.appPreferences.positionBehavior(markerTimeline: markerTimeline) == .rememberPosition
|
||||||
lastReadId.compactMap { $0 }
|
lastReadId.compactMap { $0 }
|
||||||
.removeDuplicates()
|
.removeDuplicates()
|
||||||
.debounce(for: 0.5, scheduler: DispatchQueue.global())
|
.debounce(for: .seconds(Self.lastReadIdDebounceInterval), scheduler: DispatchQueue.global())
|
||||||
.flatMap { identification.service.setLastReadId($0, forMarker: markerTimeline) }
|
.flatMap { identification.service.setLastReadId($0, forMarker: markerTimeline) }
|
||||||
.sink { _ in } receiveValue: { _ in }
|
.sink { _ in } receiveValue: { _ in }
|
||||||
.store(in: &cancellables)
|
.store(in: &cancellables)
|
||||||
|
@ -283,6 +283,8 @@ extension CollectionItemsViewModel: CollectionViewModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
private extension CollectionItemsViewModel {
|
private extension CollectionItemsViewModel {
|
||||||
|
private static let lastReadIdDebounceInterval: TimeInterval = 0.5
|
||||||
|
|
||||||
var lastUpdateWasContextParentOnly: Bool {
|
var lastUpdateWasContextParentOnly: Bool {
|
||||||
collectionService is ContextService && lastUpdate.items.map(\.count) == [0, 1, 0]
|
collectionService is ContextService && lastUpdate.items.map(\.count) == [0, 1, 0]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue