From f82d7f8ec796bc60bd96b671aa4e770c268a0b8f Mon Sep 17 00:00:00 2001 From: SeokjuneHong Date: Sat, 28 Mar 2026 22:14:23 +0900 Subject: [PATCH] =?UTF-8?q?Fix:=20=EC=9D=B5=EB=AA=85=20=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EC=9D=B8=20=EC=83=9D=EC=84=B1=20=EB=82=A0=EC=A7=9C=EC=99=80=20?= =?UTF-8?q?=EC=B5=9C=EC=A2=85=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EB=82=A0?= =?UTF-8?q?=EC=A7=9C=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - createAt: 계정 생성 시에만 설정 (변경 없음) - lastSeenAt: 앱 진입(foreground) 시마다 업데이트하도록 변경 - UpdateLastSeenAtUseCase 추가 및 sceneWillEnterForeground에서 호출 - CheckUserRegistrationUseCase에서 중복 updateLastSeenAt 호출 제거 - .gitignore 추가 Co-Authored-By: Claude Opus 4.6 (1M context) --- .gitignore | 36 +++++++++++++++++++ BanGiDa/Application/DIContainer.swift | 7 ++++ BanGiDa/Application/SceneDelegate.swift | 12 +++++++ .../User/CheckUserRegistrationUseCase.swift | 8 +---- .../User/UpdateLastSeenAtUseCase.swift | 25 +++++++++++++ 5 files changed, 81 insertions(+), 7 deletions(-) create mode 100644 .gitignore create mode 100644 BanGiDa/UseCase/User/UpdateLastSeenAtUseCase.swift diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..349726f --- /dev/null +++ b/.gitignore @@ -0,0 +1,36 @@ +# Xcode +*.xcodeproj/xcuserdata/ +*.xcodeproj/project.xcworkspace/xcuserdata/ +*.xcworkspace/xcuserdata/ +DerivedData/ +build/ +*.ipa +*.dSYM.zip +*.dSYM + +# CocoaPods +Pods/ + +# SPM +.build/ +Package.resolved + +# oh-my-claudecode +.omc/ + +# Claude Code +.claude/ + +# OS +.DS_Store +*.swp +*~ + +# Firebase +GoogleService-Info.plist + +# Secrets +*.env +*.pem +*.p12 +*.key diff --git a/BanGiDa/Application/DIContainer.swift b/BanGiDa/Application/DIContainer.swift index b863d5a..a5109aa 100644 --- a/BanGiDa/Application/DIContainer.swift +++ b/BanGiDa/Application/DIContainer.swift @@ -48,6 +48,13 @@ final class AppDIContainer { return CheckUserRegistrationUseCaseImpl(userRepository: userRepository) } + container.register(UpdateLastSeenAtUseCase.self) { resolver in + guard let userRepository = resolver.resolve(UserRepository.self) else { + fatalError("UserRepository dependency has not been registered.") + } + return UpdateLastSeenAtUseCaseImpl(userRepository: userRepository) + } + container.register(UpdateNicknameUseCase.self) { resolver in guard let userRepository = resolver.resolve(UserRepository.self) else { fatalError("UserRepository dependency has not been registered.") diff --git a/BanGiDa/Application/SceneDelegate.swift b/BanGiDa/Application/SceneDelegate.swift index b91d95a..848e549 100644 --- a/BanGiDa/Application/SceneDelegate.swift +++ b/BanGiDa/Application/SceneDelegate.swift @@ -13,6 +13,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { @Injected private var checkUserRegistrationUseCase: CheckUserRegistrationUseCase @Injected private var createAuthUserUseCase: CreateAuthUserUseCase + @Injected private var updateLastSeenAtUseCase: UpdateLastSeenAtUseCase func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. @@ -48,6 +49,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { func sceneWillEnterForeground(_ scene: UIScene) { // Called as the scene transitions from the background to the foreground. // Use this method to undo the changes made on entering the background. + updateLastSeenAt() } func sceneDidEnterBackground(_ scene: UIScene) { @@ -68,5 +70,15 @@ private extension SceneDelegate { } } } + + func updateLastSeenAt() { + Task { + do { + try await updateLastSeenAtUseCase.execute() + } catch { + print("updateLastSeenAt Error: ", error) + } + } + } } diff --git a/BanGiDa/UseCase/User/CheckUserRegistrationUseCase.swift b/BanGiDa/UseCase/User/CheckUserRegistrationUseCase.swift index 323c3f3..4a7c9a0 100644 --- a/BanGiDa/UseCase/User/CheckUserRegistrationUseCase.swift +++ b/BanGiDa/UseCase/User/CheckUserRegistrationUseCase.swift @@ -21,12 +21,6 @@ public final class CheckUserRegistrationUseCaseImpl: CheckUserRegistrationUseCas public func execute() async throws -> Bool { guard let uid = userRepository.loadUID() else { return false } - let result = try await userRepository.checkRegistration(uid: uid) - - if result { - try await userRepository.updateLastSeenAt() - } - - return result + return try await userRepository.checkRegistration(uid: uid) } } diff --git a/BanGiDa/UseCase/User/UpdateLastSeenAtUseCase.swift b/BanGiDa/UseCase/User/UpdateLastSeenAtUseCase.swift new file mode 100644 index 0000000..c91b842 --- /dev/null +++ b/BanGiDa/UseCase/User/UpdateLastSeenAtUseCase.swift @@ -0,0 +1,25 @@ +// +// UpdateLastSeenAtUseCase.swift +// BanGiDa +// +// Created by 홍석준 on 3/28/26. +// + +import Foundation + +public protocol UpdateLastSeenAtUseCase { + func execute() async throws +} + +public final class UpdateLastSeenAtUseCaseImpl: UpdateLastSeenAtUseCase { + private let userRepository: UserRepository + + public init(userRepository: UserRepository) { + self.userRepository = userRepository + } + + public func execute() async throws { + guard userRepository.loadUID() != nil else { return } + try await userRepository.updateLastSeenAt() + } +}