하트 랭킹 추가

This commit is contained in:
Yu Sung
2024-11-12 00:33:28 +09:00
parent fb5d7bd209
commit b4f99af291
9 changed files with 349 additions and 2 deletions

View File

@@ -97,6 +97,8 @@ final class LiveRoomViewModel: NSObject, ObservableObject {
@Published var isShowDonationRankingPopup = false
@Published var isShowHeartRankingPopup = false
@Published var isSpeakerFold = false
@Published var isShowQuitPopup = false
@@ -130,6 +132,7 @@ final class LiveRoomViewModel: NSObject, ObservableObject {
@Published var isBgOn = true
@Published var isSignatureOn = true
@Published var donationStatus: GetLiveRoomDonationStatusResponse?
@Published var heartStatus: GetLiveRoomHeartListResponse?
@Published private(set) var offset: CGFloat = 0
@Published private(set) var originOffset: CGFloat = 0
@@ -1027,6 +1030,39 @@ final class LiveRoomViewModel: NSObject, ObservableObject {
.store(in: &subscription)
}
func getHeartStatus() {
isLoading = true
repository.heartStatus(roomId: AppState.shared.roomId)
.sink { result in
switch result {
case .finished:
DEBUG_LOG("finish")
case .failure(let error):
ERROR_LOG(error.localizedDescription)
}
} receiveValue: { [unowned self] response in
self.isLoading = false
let responseData = response.data
do {
let jsonDecoder = JSONDecoder()
let decoded = try jsonDecoder.decode(ApiResponse<GetLiveRoomHeartListResponse>.self, from: responseData)
if let data = decoded.data, decoded.success {
self.heartStatus = data
} else {
self.errorMessage = "하트 랭킹을 가져오지 못했습니다\n다시 시도해 주세요."
self.isShowPopup = true
}
} catch {
self.isLoading = false
self.errorMessage = "하트 랭킹을 가져오지 못했습니다\n다시 시도해 주세요."
self.isShowPopup = true
}
}
.store(in: &subscription)
}
func creatorFollow(creatorId: Int? = nil, isGetUserProfile: Bool = false) {
var userId = 0