Skip to content

Commit d796083

Browse files
authored
Merge pull request #90 from OlegEremenko991/bugfix
Поправил логику setHasSportsGrounds в UserDefaults
2 parents ad15dbd + 0fe6e23 commit d796083

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

SwiftUI-WorkoutApp/Services/DefaultsService.swift

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ protocol DefaultsProtocol: AnyObject {
2323
func saveUnreadMessagesCount(_ count: Int)
2424
func saveBlacklist(_ array: [UserResponse]) throws
2525
func setHasJournals(_ hasJournals: Bool)
26-
func setHasSportsGrounds(_ hasGrounds: Bool)
26+
func setHasSportsGrounds(_ isAddedGround: Bool)
2727
func triggerLogout()
2828
}
2929

@@ -150,8 +150,16 @@ final class DefaultsService: ObservableObject, DefaultsProtocol {
150150
self.hasJournals = hasJournals
151151
}
152152

153-
func setHasSportsGrounds(_ hasGrounds: Bool) {
154-
hasSportsGrounds = hasGrounds
153+
func setHasSportsGrounds(_ isAddedGround: Bool) {
154+
switch (hasSportsGrounds, isAddedGround) {
155+
case (true, true), (false, false): break
156+
case (true, false):
157+
if mainUserInfo?.usedSportsGroundsCount == 1 {
158+
hasSportsGrounds = false
159+
}
160+
case (false, true):
161+
hasSportsGrounds = true
162+
}
155163
}
156164

157165
func saveUnreadMessagesCount(_ count: Int) {

0 commit comments

Comments
 (0)