|
- import Foundation
-
- public extension MeetupId {
- static func shouldEnableJoin(_ c: MeetupIdContext) -> Bool? {
- guard !c.isLoading.value else { return nil }
-
- if
- c.textUI.isRecent,
- let sid = formatId(c.textUI.value)
- {
- return sid.count > 2
- }
-
- if c.join {
- return false
- }
-
- if
- c.isLoading.isRecent,
- !c.isLoading.value
- {
- return true
- }
-
- 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,
- !c.isLoading.value
- {
- return true
- }
-
- if
- c.finishLoading,
- c.isLoading.value
- {
- return false
- }
-
- return nil
- }
-
- static func shouldResetText(_ c: MeetupIdContext) -> String? {
- guard c.textUI.isRecent else { return nil }
- return formatId(c.textUI.value)
- }
- }
|