From 92e7f715d5975776e02d98a00c22cae44a76dd7a Mon Sep 17 00:00:00 2001 From: Jihyun247 Date: Thu, 22 Aug 2024 01:45:06 +0900 Subject: [PATCH] =?UTF-8?q?feature:=20Splash=20=EC=98=A4=ED=94=84=EB=9D=BC?= =?UTF-8?q?=EC=9D=B8=20=EB=AA=A8=EB=93=9C=20UI=20=EB=8C=80=EC=9D=91=20-=20?= =?UTF-8?q?db=ED=85=8C=EC=9D=B4=EB=B8=94=20=EC=A1=B4=EC=9E=AC=EC=97=AC?= =?UTF-8?q?=EB=B6=80=20=ED=99=95=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SplashFeature/Sources/SplashCore.swift | 37 ++++++++++++------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/Projects/Feature/SplashFeature/Sources/SplashCore.swift b/Projects/Feature/SplashFeature/Sources/SplashCore.swift index 8f83f0c..97a8f99 100644 --- a/Projects/Feature/SplashFeature/Sources/SplashCore.swift +++ b/Projects/Feature/SplashFeature/Sources/SplashCore.swift @@ -25,7 +25,6 @@ public struct SplashCore { public init() { } var width: CGFloat = .zero var isLoggedIn: Bool = false - var networkOffCount: Int = 0 var dialog: DefaultDialog? } @@ -34,6 +33,8 @@ public struct SplashCore { case task case didFinishInitializeDatabase case _fetchNetworkConnection(Bool) + case _checkDeviceIDExist + case presentNetworkDialog case moveToHome case moveToOnboarding case binding(BindingAction) @@ -73,15 +74,28 @@ public struct SplashCore { case ._fetchNetworkConnection(let isConnected): if isConnected { - return checkDeviceIDExist() - } else if !isConnected && state.networkOffCount > 1 { - state.dialog = DefaultDialog( - title: "네트워크 연결을 확인해주세요", - firstButton: DialogButtonModel(title: "확인") - ) - } else if !isConnected { - state.networkOffCount += 1 + return .run { send in + await send(._checkDeviceIDExist) + } + } else { + return .run { send in + if try await !databaseClient.checkHasTable() { + await send(.presentNetworkDialog) + } else { + await send(._checkDeviceIDExist) + } + } } + + case ._checkDeviceIDExist: + let deviceID = keychainClient.read(key: deviceIDKey) ?? getDeviceUUID() + return login(deviceID: deviceID) + + case .presentNetworkDialog: + state.dialog = DefaultDialog( + title: "네트워크 연결을 확인해주세요", + firstButton: DialogButtonModel(title: "확인") + ) return .none case .moveToHome: @@ -97,11 +111,6 @@ public struct SplashCore { } extension SplashCore { - private func checkDeviceIDExist() -> Effect { - let deviceID = keychainClient.read(key: deviceIDKey) ?? getDeviceUUID() - return login(deviceID: deviceID) - } - private func login(deviceID: String) -> Effect { return .run { send in try await authService.login(