feat(creator): 답글 상세 모델을 추가한다
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
import Foundation
|
||||
|
||||
enum CreatorChannelReplyDetailContext {
|
||||
case community(
|
||||
creatorId: Int,
|
||||
postId: Int,
|
||||
parentComment: GetCommunityPostCommentListItem
|
||||
)
|
||||
case fanTalk(
|
||||
creatorId: Int,
|
||||
parentFanTalk: CreatorChannelFanTalkItemResponse
|
||||
)
|
||||
}
|
||||
@@ -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
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user