시리즈 상세 - 크리에이터 팔로우와 알림설정
- 팔로잉 상태에서 알림 켜기/끄기 상태 추가
This commit is contained in:
@@ -18,6 +18,7 @@ final class SeriesDetailViewModel: ObservableObject {
|
||||
@Published var isShowPopup = false
|
||||
|
||||
@Published var isFollow: Bool = false
|
||||
@Published var isNotify: Bool = false
|
||||
@Published var seriesDetail: GetSeriesDetailResponse? = nil
|
||||
|
||||
var seriesId: Int = 0
|
||||
@@ -44,6 +45,7 @@ final class SeriesDetailViewModel: ObservableObject {
|
||||
if let data = decoded.data, decoded.success {
|
||||
self.seriesDetail = data
|
||||
self.isFollow = data.creator.isFollow
|
||||
self.isNotify = data.creator.isNotify
|
||||
} else {
|
||||
if let message = decoded.message {
|
||||
self.errorMessage = message
|
||||
@@ -63,10 +65,10 @@ final class SeriesDetailViewModel: ObservableObject {
|
||||
.store(in: &subscription)
|
||||
}
|
||||
|
||||
func follow(_ creatorId: Int) {
|
||||
func follow(_ creatorId: Int, follow: Bool = true, notify: Bool = true) {
|
||||
isLoading = true
|
||||
|
||||
userRepository.creatorFollow(creatorId: creatorId)
|
||||
userRepository.creatorFollow(creatorId: creatorId, follow: follow, notify: notify)
|
||||
.sink { result in
|
||||
switch result {
|
||||
case .finished:
|
||||
@@ -83,7 +85,8 @@ final class SeriesDetailViewModel: ObservableObject {
|
||||
let decoded = try jsonDecoder.decode(ApiResponseWithoutData.self, from: responseData)
|
||||
|
||||
if decoded.success {
|
||||
self.isFollow = !self.isFollow
|
||||
self.isFollow = follow
|
||||
self.isNotify = notify
|
||||
} else {
|
||||
if let message = decoded.message {
|
||||
self.errorMessage = message
|
||||
|
||||
Reference in New Issue
Block a user