Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions BanGiDa/Application/DIContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down
12 changes: 12 additions & 0 deletions BanGiDa/Application/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down Expand Up @@ -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) {
Expand All @@ -68,5 +70,15 @@ private extension SceneDelegate {
}
}
}

func updateLastSeenAt() {
Task {
do {
try await updateLastSeenAtUseCase.execute()
} catch {
print("updateLastSeenAt Error: ", error)
}
}
}
}

8 changes: 1 addition & 7 deletions BanGiDa/UseCase/User/CheckUserRegistrationUseCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
25 changes: 25 additions & 0 deletions BanGiDa/UseCase/User/UpdateLastSeenAtUseCase.swift
Original file line number Diff line number Diff line change
@@ -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()
}
}