From 2d7c12b227b2911b0deef0a68e2c1ddf7d95641a Mon Sep 17 00:00:00 2001 From: jim4020key Date: Sun, 16 Jul 2023 20:48:11 +0900 Subject: [PATCH] [Feat] #473 - Sort comments --- .../HappyAnding/ViewModel/ReadShortcutViewModel.swift | 5 +++++ .../Views/ReadShortcutViews/ReadShortcutView.swift | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/HappyAnding/HappyAnding/ViewModel/ReadShortcutViewModel.swift b/HappyAnding/HappyAnding/ViewModel/ReadShortcutViewModel.swift index 92e32ea3..34dbcf51 100644 --- a/HappyAnding/HappyAnding/ViewModel/ReadShortcutViewModel.swift +++ b/HappyAnding/HappyAnding/ViewModel/ReadShortcutViewModel.swift @@ -106,6 +106,7 @@ final class ReadShortcutViewModel: ObservableObject { shortcutsZipViewModel.setData(model: comments) commentText = "" comment = comment.resetComment() + self.comments.comments = comments.fetchSortedComment() } func cancelNestedComment() { @@ -147,4 +148,8 @@ final class ReadShortcutViewModel: ObservableObject { shortcutsZipViewModel.setData(model: comments) } + + func fetchUserGrade(id: String) -> Image { + shortcutsZipViewModel.fetchShortcutGradeImage(isBig: false, shortcutGrade: shortcutsZipViewModel.checkShortcutGrade(userID: id)) + } } diff --git a/HappyAnding/HappyAnding/Views/ReadShortcutViews/ReadShortcutView.swift b/HappyAnding/HappyAnding/Views/ReadShortcutViews/ReadShortcutView.swift index a6a234e7..cc4693b1 100644 --- a/HappyAnding/HappyAnding/Views/ReadShortcutViews/ReadShortcutView.swift +++ b/HappyAnding/HappyAnding/Views/ReadShortcutViews/ReadShortcutView.swift @@ -642,7 +642,7 @@ extension ReadShortcutView { /// 유저 정보 HStack(spacing: 8) { - shortcutsZipViewModel.fetchShortcutGradeImage(isBig: false, shortcutGrade: shortcutsZipViewModel.checkShortcutGrade(userID: comment.user_id )) + viewModel.fetchUserGrade(id: comment.user_id) .font(.system(size: 24, weight: .medium)) .frame(width: 24, height: 24) .foregroundColor(.gray3) @@ -653,7 +653,6 @@ extension ReadShortcutView { } .padding(.bottom, 4) - /// 댓글 내용 Text(comment.contents) .shortcutsZipBody2()