오디션
- 오디션 알림 받기 설정 추가
This commit is contained in:
@@ -11,6 +11,7 @@ import Combine
|
||||
final class AuditionViewModel: ObservableObject {
|
||||
|
||||
private let repository = AuditionRepository()
|
||||
private let userRepository = UserRepository()
|
||||
private var subscription = Set<AnyCancellable>()
|
||||
|
||||
@Published var errorMessage = ""
|
||||
@@ -80,4 +81,30 @@ final class AuditionViewModel: ObservableObject {
|
||||
.store(in: &subscription)
|
||||
}
|
||||
}
|
||||
|
||||
func updateNotificationSettings() {
|
||||
let isAuditionNotification = UserDefaults.bool(forKey: .isAuditionNotification)
|
||||
|
||||
userRepository.updateNotificationSettings(audition: !isAuditionNotification)
|
||||
.sink { result in
|
||||
switch result {
|
||||
case .finished:
|
||||
DEBUG_LOG("finish")
|
||||
case .failure(let error):
|
||||
ERROR_LOG(error.localizedDescription)
|
||||
}
|
||||
} receiveValue: { response in
|
||||
let responseData = response.data
|
||||
|
||||
do {
|
||||
let jsonDecoder = JSONDecoder()
|
||||
let decoded = try jsonDecoder.decode(ApiResponseWithoutData.self, from: responseData)
|
||||
|
||||
if decoded.success {
|
||||
UserDefaults.set(!isAuditionNotification, forKey: .isAuditionNotification)
|
||||
}
|
||||
} catch {}
|
||||
}
|
||||
.store(in: &subscription)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user