fix(deeplink): 커뮤니티 링크를 게시글 상세에 연결한다

This commit is contained in:
Yu Sung
2026-10-13 13:57:44 +09:00
parent 1b50f559bd
commit 4b5fa133f5
2 changed files with 83 additions and 28 deletions
+16 -25
View File
@@ -6,7 +6,7 @@ enum AppDeepLinkAction {
case content(contentId: Int)
case series(seriesId: Int)
case giftDetail(applicationNo: String)
case community(creatorId: Int, postId: Int?)
case community(postId: Int)
case message
case audition
}
@@ -74,16 +74,9 @@ enum AppDeepLinkHandler {
case .giftDetail(let applicationNo):
AppState.shared.setAppStep(step: .giftDetail(applicationNo: applicationNo))
case .community(let creatorId, let postId):
guard creatorId > 0 else { return }
if let postId = postId, postId > 0 {
AppState.shared.setPendingCommunityCommentDeepLink(creatorId: creatorId, postId: postId)
} else {
AppState.shared.clearPendingCommunityCommentDeepLink()
}
AppState.shared.setAppStep(step: .creatorCommunityAll(creatorId: creatorId))
case .community(let postId):
guard postId > 0 else { return }
AppState.shared.setAppStep(step: .creatorChannelCommunityPostDetail(postId: postId))
case .message:
AppState.shared.setAppStep(step: .message)
@@ -104,6 +97,12 @@ enum AppDeepLinkHandler {
private static func parseAction(url: URL) -> AppDeepLinkAction? {
let components = URLComponents(url: url, resolvingAgainstBaseURL: false)
let host = components?.host?.lowercased() ?? ""
let pathRoute = url.pathComponents.first { $0 != "/" && !$0.isEmpty }?.lowercased()
if host == "community" || (host.isEmpty && pathRoute == "community") {
return parsePathStyle(url: url, components: components)
}
if let routeAction = parsePathStyle(url: url, components: components) {
return routeAction
@@ -160,7 +159,10 @@ enum AppDeepLinkHandler {
}
if let communityId = queryMap["community_id"], let value = Int(communityId), value > 0 {
return .community(creatorId: value, postId: communityPostId(queryMap: queryMap))
guard let postId = communityPostId(queryMap: queryMap) else {
return nil
}
return .community(postId: postId)
}
if queryMap["message_id"] != nil {
@@ -208,17 +210,10 @@ enum AppDeepLinkHandler {
return .giftDetail(applicationNo: applicationNo)
case "community":
let postId = communityPostId(queryItems: components?.queryItems)
if let identifier = identifier, let creatorId = Int(identifier), creatorId > 0 {
return .community(creatorId: creatorId, postId: postId)
}
guard let creatorId = fallbackCommunityCreatorId() else {
guard let postId = communityPostId(queryItems: components?.queryItems) else {
return nil
}
return .community(creatorId: creatorId, postId: postId)
return .community(postId: postId)
case "message":
return .message
@@ -256,8 +251,4 @@ enum AppDeepLinkHandler {
return nil
}
private static func fallbackCommunityCreatorId() -> Int? {
let userId = UserDefaults.int(forKey: .userId)
return userId > 0 ? userId : nil
}
}