From c356815b3e2138112ed177f19f42d87e44544646 Mon Sep 17 00:00:00 2001 From: Yu Sung Date: Tue, 7 Jul 2026 15:03:49 +0900 Subject: [PATCH] =?UTF-8?q?feat(creator):=20=EB=8B=B5=EA=B8=80=20=EC=83=81?= =?UTF-8?q?=EC=84=B8=20=EB=AA=A8=EB=8D=B8=EC=9D=84=20=EC=B6=94=EA=B0=80?= =?UTF-8?q?=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CreatorChannelReplyDetailContext.swift | 13 +++ ...CreatorChannelReplyDetailDisplayItem.swift | 92 +++++++++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 SodaLive/Sources/V2/CreatorChannel/ReplyDetail/Models/CreatorChannelReplyDetailContext.swift create mode 100644 SodaLive/Sources/V2/CreatorChannel/ReplyDetail/Models/CreatorChannelReplyDetailDisplayItem.swift diff --git a/SodaLive/Sources/V2/CreatorChannel/ReplyDetail/Models/CreatorChannelReplyDetailContext.swift b/SodaLive/Sources/V2/CreatorChannel/ReplyDetail/Models/CreatorChannelReplyDetailContext.swift new file mode 100644 index 00000000..a5f6899d --- /dev/null +++ b/SodaLive/Sources/V2/CreatorChannel/ReplyDetail/Models/CreatorChannelReplyDetailContext.swift @@ -0,0 +1,13 @@ +import Foundation + +enum CreatorChannelReplyDetailContext { + case community( + creatorId: Int, + postId: Int, + parentComment: GetCommunityPostCommentListItem + ) + case fanTalk( + creatorId: Int, + parentFanTalk: CreatorChannelFanTalkItemResponse + ) +} diff --git a/SodaLive/Sources/V2/CreatorChannel/ReplyDetail/Models/CreatorChannelReplyDetailDisplayItem.swift b/SodaLive/Sources/V2/CreatorChannel/ReplyDetail/Models/CreatorChannelReplyDetailDisplayItem.swift new file mode 100644 index 00000000..6db52bc5 --- /dev/null +++ b/SodaLive/Sources/V2/CreatorChannel/ReplyDetail/Models/CreatorChannelReplyDetailDisplayItem.swift @@ -0,0 +1,92 @@ +import Foundation + +struct CreatorChannelReplyDetailDisplayItem: Identifiable, Equatable { + enum Source: Equatable { + case community + case fanTalk + } + + let id: Int + let source: Source + let writerId: Int + let nickname: String + let profileImageUrl: String + let content: String + let relativeTimeText: String + let isSecret: Bool + let isMine: Bool + let isCreatorReply: Bool + + var canEdit: Bool { + isMine || isCreatorReply + } + + var canDelete: Bool { + isMine || isCreatorReply + } + + func updatingContent(_ content: String) -> CreatorChannelReplyDetailDisplayItem { + CreatorChannelReplyDetailDisplayItem( + id: id, + source: source, + writerId: writerId, + nickname: nickname, + profileImageUrl: profileImageUrl, + content: content, + relativeTimeText: relativeTimeText, + isSecret: isSecret, + isMine: isMine, + isCreatorReply: isCreatorReply + ) + } +} + +extension CreatorChannelReplyDetailDisplayItem { + init(communityComment: GetCommunityPostCommentListItem) { + let currentUserId = UserDefaults.int(forKey: .userId) + self.init( + id: communityComment.id, + source: .community, + writerId: communityComment.writerId, + nickname: communityComment.nickname, + profileImageUrl: communityComment.profileUrl, + content: communityComment.comment, + relativeTimeText: communityComment.date, + isSecret: communityComment.isSecret, + isMine: communityComment.writerId == currentUserId, + isCreatorReply: false + ) + } + + init(fanTalk: CreatorChannelFanTalkItemResponse) { + let currentUserId = UserDefaults.int(forKey: .userId) + self.init( + id: fanTalk.fanTalkId, + source: .fanTalk, + writerId: fanTalk.writerId, + nickname: fanTalk.writerNickname, + profileImageUrl: fanTalk.writerProfileImageUrl, + content: fanTalk.content, + relativeTimeText: fanTalk.relativeTimeText(), + isSecret: false, + isMine: fanTalk.writerId == currentUserId, + isCreatorReply: false + ) + } + + init(fanTalkReply: CreatorChannelFanTalkReplyResponse, creatorId: Int) { + let currentUserId = UserDefaults.int(forKey: .userId) + self.init( + id: fanTalkReply.fanTalkId, + source: .fanTalk, + writerId: fanTalkReply.writerId, + nickname: fanTalkReply.writerNickname, + profileImageUrl: fanTalkReply.writerProfileImageUrl, + content: fanTalkReply.content, + relativeTimeText: fanTalkReply.relativeTimeText(), + isSecret: false, + isMine: fanTalkReply.writerId == currentUserId, + isCreatorReply: fanTalkReply.writerId == creatorId + ) + } +}