From f983eb9f572948a6cb2f53336dda6f23cf366c70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Tue, 2 Jan 2024 10:28:05 +0300 Subject: [PATCH] d --- Modules/MeetupIdX/src/MeetupId.Aux.swift | 5 ----- Modules/MeetupIdX/src/MeetupId.Shoulds.swift | 15 +++++++++++++++ Modules/MeetupIdX/src/MeetupId.V.swift | 16 +++++++++------- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/Modules/MeetupIdX/src/MeetupId.Aux.swift b/Modules/MeetupIdX/src/MeetupId.Aux.swift index 57c71e1..884cfa9 100644 --- a/Modules/MeetupIdX/src/MeetupId.Aux.swift +++ b/Modules/MeetupIdX/src/MeetupId.Aux.swift @@ -1,11 +1,6 @@ import Foundation public extension MeetupId { - static func finishLoading(_ isLoading: Bool) -> Bool? { - guard isLoading else { return nil } - return true - } - static func formatId(_ s: String) -> String? { let digits = s.components(separatedBy: NSCharacterSet.decimalDigits.inverted).reduce("") { $0 + $1 } var r = "" diff --git a/Modules/MeetupIdX/src/MeetupId.Shoulds.swift b/Modules/MeetupIdX/src/MeetupId.Shoulds.swift index de08719..2a2d4dc 100644 --- a/Modules/MeetupIdX/src/MeetupId.Shoulds.swift +++ b/Modules/MeetupIdX/src/MeetupId.Shoulds.swift @@ -25,6 +25,16 @@ public extension MeetupId { return nil } + static func shouldFinishLoading(_ c: MeetupIdContext) -> Bool? { + guard + c.isLoading.isRecent, + c.isLoading.value + else { + return nil + } + return true + } + static func shouldResetLoading(_ c: MeetupIdContext) -> Bool? { if c.join, @@ -42,4 +52,9 @@ public extension MeetupId { return nil } + + static func shouldResetText(_ c: MeetupIdContext) -> String? { + guard c.textUI.isRecent else { return nil } + return formatId(c.textUI.value) + } } diff --git a/Modules/MeetupIdX/src/MeetupId.V.swift b/Modules/MeetupIdX/src/MeetupId.V.swift index 1e616a3..a8822a7 100644 --- a/Modules/MeetupIdX/src/MeetupId.V.swift +++ b/Modules/MeetupIdX/src/MeetupId.V.swift @@ -7,14 +7,16 @@ extension MeetupId { @StateObject var isLoading = BusUI.Value(K.isLoading, false) @StateObject var join = BusUI.Button(K.join) @StateObject var textField = BusUI.TextField(K.textApp, K.textUI) - let processors: [Any] = [ - Bus.Debounce(formatId, 0.2, K.textUI, K.textApp), - Bus.Delay(finishLoading, 5, K.isLoading, K.finishLoading), - Bus.Sync(shouldEnableJoin, K.M, K.isJoinAvailable), - Bus.Sync(shouldResetLoading, K.M, K.isLoading) - ] + let processors: [Any] - public init() { } + public init() { + processors = [ + Bus.Debounce(shouldResetText, 0.2, K.M, K.textApp), + Bus.Delay(shouldFinishLoading, 5, K.M, K.finishLoading), + Bus.Sync(shouldEnableJoin, K.M, K.isJoinAvailable), + Bus.Sync(shouldResetLoading, K.M, K.isLoading) + ] + } public var body: some View { VStack(spacing: 8) {