From 7481637fbb0081708bfb2d1e783e47a04be862cb Mon Sep 17 00:00:00 2001 From: Yu Sung Date: Thu, 9 Jan 2025 00:38:29 +0900 Subject: [PATCH] =?UTF-8?q?=EC=98=A4=EB=94=94=EC=85=98=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20=ED=91=B8=EC=8B=9C=EB=A5=BC=20=EB=B0=9B=EC=9C=BC?= =?UTF-8?q?=EB=A9=B4=20=EC=98=A4=EB=94=94=EC=85=98=20=ED=83=AD=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EC=9D=B4=EB=8F=99=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SodaLive/Sources/App/AppDelegate.swift | 10 ++++++++++ SodaLive/Sources/App/AppState.swift | 1 + SodaLive/Sources/Main/Home/HomeViewModel.swift | 15 ++++++++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/SodaLive/Sources/App/AppDelegate.swift b/SodaLive/Sources/App/AppDelegate.swift index 04dae80..9ad38f8 100644 --- a/SodaLive/Sources/App/AppDelegate.swift +++ b/SodaLive/Sources/App/AppDelegate.swift @@ -97,6 +97,7 @@ extension AppDelegate : UNUserNotificationCenterDelegate { let contentIdString = userInfo["content_id"] as? String let channelIdString = userInfo["channel_id"] as? String let messageIdString = userInfo["message_id"] as? String + let auditionIdString = userInfo["audition_id"] as? String if let roomIdString = roomIdString, let roomId = Int(roomIdString), roomId > 0 { AppState.shared.pushRoomId = roomId @@ -114,6 +115,15 @@ extension AppDelegate : UNUserNotificationCenterDelegate { AppState.shared.pushMessageId = messageId } + if let auditionIdString = auditionIdString, let auditionId = Int(auditionIdString), auditionId > 0 { + AppState.shared.startTab = .audition + NotificationCenter.default.post(name: .didReceiveHomeTab, object: HomeViewModel.CurrentTab.audition) + } + completionHandler() } } + +extension Notification.Name { + static let didReceiveHomeTab = Notification.Name("didReceiveHomeTab") +} diff --git a/SodaLive/Sources/App/AppState.swift b/SodaLive/Sources/App/AppState.swift index 2934709..3f6c965 100644 --- a/SodaLive/Sources/App/AppState.swift +++ b/SodaLive/Sources/App/AppState.swift @@ -42,6 +42,7 @@ class AppState: ObservableObject { @Published var purchasedContentOrderType = OrderType.KEEP @Published var isChangeAdultContentVisible = false + @Published var startTab: HomeViewModel.CurrentTab = .content func setAppStep(step: AppStep) { switch step { diff --git a/SodaLive/Sources/Main/Home/HomeViewModel.swift b/SodaLive/Sources/Main/Home/HomeViewModel.swift index 729e3db..1cfd66e 100644 --- a/SodaLive/Sources/Main/Home/HomeViewModel.swift +++ b/SodaLive/Sources/Main/Home/HomeViewModel.swift @@ -24,7 +24,20 @@ final class HomeViewModel: ObservableObject { case content, live, audition, message, mypage } - @Published var currentTab: CurrentTab = .content + @Published var currentTab: CurrentTab = AppState.shared.startTab + + init() { + NotificationCenter.default + .publisher(for: .didReceiveHomeTab) + .compactMap { + $0.object as? CurrentTab + } + .sink { [weak self] currentTab in + AppState.shared.setAppStep(step: .main) + self?.currentTab = currentTab + } + .store(in: &subscription) + } func pushTokenUpdate(pushToken: String) { userRepository.updatePushToken(pushToken: pushToken)