룰렛 프리셋 설정 성공 메시지 수정
This commit is contained in:
parent
fec66fea56
commit
0584b17b76
|
@ -1341,8 +1341,8 @@ final class LiveRoomViewModel: NSObject, ObservableObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func setActiveRoulette(isActiveRoulette: Bool) {
|
func setActiveRoulette(isActiveRoulette: Bool, message: String) {
|
||||||
self.popupContent = isActiveRoulette ? "룰렛을 활성화 했습니다." : "룰렛을 비활성화 했습니다."
|
self.popupContent = message
|
||||||
self.isShowPopup = true
|
self.isShowPopup = true
|
||||||
self.agora.sendRawMessageToGroup(
|
self.agora.sendRawMessageToGroup(
|
||||||
rawMessage: LiveRoomChatRawMessage(
|
rawMessage: LiveRoomChatRawMessage(
|
||||||
|
|
|
@ -13,7 +13,7 @@ struct RouletteSettingsView: View {
|
||||||
@StateObject var viewModel = RouletteSettingsViewModel()
|
@StateObject var viewModel = RouletteSettingsViewModel()
|
||||||
|
|
||||||
@Binding var isShowing: Bool
|
@Binding var isShowing: Bool
|
||||||
let onComplete: (Bool) -> Void
|
let onComplete: (Bool, String) -> Void
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
GeometryReader { proxy in
|
GeometryReader { proxy in
|
||||||
|
@ -163,7 +163,7 @@ struct RouletteSettingsView: View {
|
||||||
.cornerRadius(10)
|
.cornerRadius(10)
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
viewModel.createOrUpdateRoulette {
|
viewModel.createOrUpdateRoulette {
|
||||||
onComplete($0)
|
onComplete($0, $1)
|
||||||
isShowing = false
|
isShowing = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -217,6 +217,6 @@ struct RouletteSettingsView: View {
|
||||||
|
|
||||||
struct RouletteSettingsView_Previews: PreviewProvider {
|
struct RouletteSettingsView_Previews: PreviewProvider {
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
RouletteSettingsView(isShowing: .constant(true)) { _ in }
|
RouletteSettingsView(isShowing: .constant(true)) { _, _ in }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,7 +148,7 @@ final class RouletteSettingsViewModel: ObservableObject {
|
||||||
isShowPreview = true
|
isShowPreview = true
|
||||||
}
|
}
|
||||||
|
|
||||||
func createOrUpdateRoulette(onSuccess: @escaping (Bool) -> Void) {
|
func createOrUpdateRoulette(onSuccess: @escaping (Bool, String) -> Void) {
|
||||||
if !isLoading {
|
if !isLoading {
|
||||||
isLoading = true
|
isLoading = true
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ final class RouletteSettingsViewModel: ObservableObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func createRoulette(onSuccess: @escaping (Bool) -> Void) {
|
private func createRoulette(onSuccess: @escaping (Bool, String) -> Void) {
|
||||||
var items = [RouletteItem]()
|
var items = [RouletteItem]()
|
||||||
for option in options {
|
for option in options {
|
||||||
if option.title.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
|
if option.title.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
|
||||||
|
@ -173,6 +173,26 @@ final class RouletteSettingsViewModel: ObservableObject {
|
||||||
items.append(RouletteItem(title: option.title, weight: option.weight))
|
items.append(RouletteItem(title: option.title, weight: option.weight))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let selectedRouletteTitle: String
|
||||||
|
let successMessage: String
|
||||||
|
|
||||||
|
switch (self.selectedRoulette) {
|
||||||
|
case .ROULETTE_2:
|
||||||
|
selectedRouletteTitle = "룰렛 2"
|
||||||
|
|
||||||
|
case .ROULETTE_3:
|
||||||
|
selectedRouletteTitle = "룰렛 3"
|
||||||
|
|
||||||
|
default:
|
||||||
|
selectedRouletteTitle = "룰렛 1"
|
||||||
|
}
|
||||||
|
|
||||||
|
if isActive {
|
||||||
|
successMessage = "\(selectedRouletteTitle)을 활성화 했습니다."
|
||||||
|
} else {
|
||||||
|
successMessage = "\(selectedRouletteTitle)을 비활성화 했습니다."
|
||||||
|
}
|
||||||
|
|
||||||
let request = CreateRouletteRequest(can: can, isActive: isActive, items: items)
|
let request = CreateRouletteRequest(can: can, isActive: isActive, items: items)
|
||||||
repository.createRoulette(request: request)
|
repository.createRoulette(request: request)
|
||||||
.sink { result in
|
.sink { result in
|
||||||
|
@ -191,7 +211,7 @@ final class RouletteSettingsViewModel: ObservableObject {
|
||||||
let decoded = try jsonDecoder.decode(ApiResponseWithoutData.self, from: responseData)
|
let decoded = try jsonDecoder.decode(ApiResponseWithoutData.self, from: responseData)
|
||||||
|
|
||||||
if decoded.success {
|
if decoded.success {
|
||||||
onSuccess(isActive)
|
onSuccess(isActive, successMessage)
|
||||||
} else {
|
} else {
|
||||||
self.errorMessage = "다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다."
|
self.errorMessage = "다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다."
|
||||||
self.isShowErrorPopup = true
|
self.isShowErrorPopup = true
|
||||||
|
@ -204,7 +224,7 @@ final class RouletteSettingsViewModel: ObservableObject {
|
||||||
.store(in: &subscription)
|
.store(in: &subscription)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func updateRoulette(onSuccess: @escaping (Bool) -> Void) {
|
private func updateRoulette(onSuccess: @escaping (Bool, String) -> Void) {
|
||||||
var items = [RouletteItem]()
|
var items = [RouletteItem]()
|
||||||
for option in options {
|
for option in options {
|
||||||
if option.title.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
|
if option.title.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
|
||||||
|
@ -263,9 +283,7 @@ final class RouletteSettingsViewModel: ObservableObject {
|
||||||
let decoded = try jsonDecoder.decode(ApiResponseWithoutData.self, from: responseData)
|
let decoded = try jsonDecoder.decode(ApiResponseWithoutData.self, from: responseData)
|
||||||
|
|
||||||
if decoded.success {
|
if decoded.success {
|
||||||
self.errorMessage = successMessage
|
onSuccess(isActive, successMessage)
|
||||||
self.isShowErrorPopup = true
|
|
||||||
onSuccess(isActive)
|
|
||||||
} else {
|
} else {
|
||||||
self.errorMessage = "다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다."
|
self.errorMessage = "다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다."
|
||||||
self.isShowErrorPopup = true
|
self.isShowErrorPopup = true
|
||||||
|
|
|
@ -548,8 +548,11 @@ struct LiveRoomViewV2: View {
|
||||||
}
|
}
|
||||||
|
|
||||||
if viewModel.isShowRouletteSettings {
|
if viewModel.isShowRouletteSettings {
|
||||||
RouletteSettingsView(isShowing: $viewModel.isShowRouletteSettings) { isActiveRoulette in
|
RouletteSettingsView(isShowing: $viewModel.isShowRouletteSettings) { isActiveRoulette, message in
|
||||||
self.viewModel.setActiveRoulette(isActiveRoulette: isActiveRoulette)
|
self.viewModel.setActiveRoulette(
|
||||||
|
isActiveRoulette: isActiveRoulette,
|
||||||
|
message: message
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue