|
- import Foundation
- import MPAKX
-
- 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 shouldManyEnableJoin(_ c: MeetupIdContext) -> MPAK.Many<Bool>? {
- var d = [String: Bool]()
-
- // TODO: Когда копировать dict isLoading?
-
- if c.textUI.isRecent {
- for id in c.textUI.keys {
- guard
- c.isLoading.dict[id] == nil
- let text = c.testTextUI.dict[id]
- else {
- continue
- }
- let sid = formatId(text)
- d[id] = sid.count > 2
- }
- if !d.isEmpty {
- return .init(Set(d.keys), d)
- }
- }
- /*
-
- if c.join,
- !c.isLoading.value
- {
- return false
- }
-
- if
- c.isLoading.isRecent,
- !c.isLoading.value
- !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
- }
- */
-
- /*
-
- это ещё конвертнуть надо в Many
-
- 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)
- }
- */
-
- static func shouldManyFinishLoading(_ c: MeetupIdContext) -> MPAK.Many<Bool>? {
- guard c.isLoading.isRecent else { return nil }
- var keys = Set<String>()
- for id in c.isLoading.keys {
- if
- let isLoading = c.isLoading.dict[id],
- isLoading
- {
- keys.insert(id)
- }
- }
- let d = [String: Bool]()
- return MPAK.Many(keys, d)
- }
-
- static func shouldManyResetText(_ c: MeetupIdContext) -> MPAK.Many<String>? {
- guard !c.textUI.keys.isEmpty else { return nil }
- var d = [String: String]()
- for id in c.textUI.keys {
- let text = c.textUI.dict[id] ?? ""
- d[id] = formatId(text)
- }
- return MPAK.Many(c.textUI.keys, d)
- }
-
- static func shouldManyTestResetText(_ c: MeetupIdContext) -> MPAK.Many<String>? {
- guard !c.testTextUI.keys.isEmpty else { return nil }
- var d = [String: String]()
- for id in c.testTextUI.keys {
- let text = c.testTextUI.dict[id] ?? ""
- d[id] = formatId(text)
- }
- return MPAK.Many(c.testTextUI.keys, d)
- }
-
- }
|