Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Network [#91] 투명도 낮추기 API 연결, 투명도 적용 토스트 메시지 분기 처리 완료, 답글 조회 API 연결 #94

Merged
merged 13 commits into from
Jan 17, 2024
Merged
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
24 changes: 24 additions & 0 deletions DontBe-iOS/DontBe-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
3C4993652B4F2471002A99CF /* MyPageSegmentedControl.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C4993642B4F2471002A99CF /* MyPageSegmentedControl.swift */; };
3C4993672B4F2644002A99CF /* MyPageContentViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C4993662B4F2644002A99CF /* MyPageContentViewController.swift */; };
3C4993692B4F2653002A99CF /* MyPageCommentViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C4993682B4F2653002A99CF /* MyPageCommentViewController.swift */; };
3C4EDCCB2B58653800A9707C /* PostReplyResponseDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C4EDCCA2B58653800A9707C /* PostReplyResponseDTO.swift */; };
3C6192ED2B3A719A00220CEB /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C6192EC2B3A719A00220CEB /* AppDelegate.swift */; };
3C6192EF2B3A719A00220CEB /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C6192EE2B3A719A00220CEB /* SceneDelegate.swift */; };
3C6192F62B3A719C00220CEB /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3C6192F52B3A719C00220CEB /* Assets.xcassets */; };
Expand Down Expand Up @@ -138,6 +139,7 @@
3CF184CB2B4EEC0B00816D5F /* MyPageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CF184CA2B4EEC0B00816D5F /* MyPageViewController.swift */; };
3CF184CD2B4EEC1900816D5F /* MyPageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CF184CC2B4EEC1900816D5F /* MyPageView.swift */; };
3CF184D12B4EFF9900816D5F /* MyPageProfileView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CF184D02B4EFF9900816D5F /* MyPageProfileView.swift */; };
3CF4651B2B58398900997FCA /* PostTransparencyRequestDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CF4651A2B58398900997FCA /* PostTransparencyRequestDTO.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand Down Expand Up @@ -238,6 +240,7 @@
3C4993642B4F2471002A99CF /* MyPageSegmentedControl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPageSegmentedControl.swift; sourceTree = "<group>"; };
3C4993662B4F2644002A99CF /* MyPageContentViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPageContentViewController.swift; sourceTree = "<group>"; };
3C4993682B4F2653002A99CF /* MyPageCommentViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPageCommentViewController.swift; sourceTree = "<group>"; };
3C4EDCCA2B58653800A9707C /* PostReplyResponseDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostReplyResponseDTO.swift; sourceTree = "<group>"; };
3C6192E92B3A719A00220CEB /* DontBe-iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "DontBe-iOS.app"; sourceTree = BUILT_PRODUCTS_DIR; };
3C6192EC2B3A719A00220CEB /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
3C6192EE2B3A719A00220CEB /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -273,6 +276,7 @@
3CF184CA2B4EEC0B00816D5F /* MyPageViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPageViewController.swift; sourceTree = "<group>"; };
3CF184CC2B4EEC1900816D5F /* MyPageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPageView.swift; sourceTree = "<group>"; };
3CF184D02B4EFF9900816D5F /* MyPageProfileView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPageProfileView.swift; sourceTree = "<group>"; };
3CF4651A2B58398900997FCA /* PostTransparencyRequestDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostTransparencyRequestDTO.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -580,6 +584,7 @@
isa = PBXGroup;
children = (
2F05B1A62B5799B700AC368D /* PostDetailResponseDTO.swift */,
3C4EDCCA2B58653800A9707C /* PostReplyResponseDTO.swift */,
);
path = ResponseDTO;
sourceTree = "<group>";
Expand Down Expand Up @@ -732,6 +737,7 @@
2FBBADFB2B564471002D6286 /* Home */,
2A28453C2B531DAD0023F9B5 /* SocialLogin */,
3C70BE2A2B53EB81001AA5A6 /* MyPage */,
3CF465182B58393800997FCA /* Transparency */,
3C61930E2B3A787000220CEB /* Foundation */,
);
path = Network;
Expand Down Expand Up @@ -1042,6 +1048,22 @@
path = ViewControllers;
sourceTree = "<group>";
};
3CF465182B58393800997FCA /* Transparency */ = {
isa = PBXGroup;
children = (
3CF465192B58394E00997FCA /* RequestDTO */,
);
path = Transparency;
sourceTree = "<group>";
};
3CF465192B58394E00997FCA /* RequestDTO */ = {
isa = PBXGroup;
children = (
3CF4651A2B58398900997FCA /* PostTransparencyRequestDTO.swift */,
);
path = RequestDTO;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -1136,6 +1158,7 @@
3CBCA3CA2B57212400D348D3 /* MyPageMemberCommentResponseDTO.swift in Sources */,
3CD25D272B5466DB0075F80F /* Empty.swift in Sources */,
2F1741882B500C270089FC4D /* UIApplication+.swift in Sources */,
3CF4651B2B58398900997FCA /* PostTransparencyRequestDTO.swift in Sources */,
3C2F544E2B50F65500E7BF01 /* DontBeBottomSheetView.swift in Sources */,
2F05B1A72B5799B700AC368D /* PostDetailResponseDTO.swift in Sources */,
3C61930C2B3A782100220CEB /* StringLiterals.swift in Sources */,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 코드 패치는 주어진 파일들을 프로젝트에 추가하는 역할을 합니다. 패치 내용을 살펴보면, 3CF4651B2B58398900997FCA 파일과 관련된 빌드 설정과 파일 참조가 추가되었습니다.

개선 사항:

  • 코드 패치에서 오류 위험이나 버그는 없어 보입니다.
  • 단, 이 코드 패치만으로는 전체적인 컨텍스트 파악이 어렵습니다. 다른 부분의 코드와의 연관성을 알 수 있는 추가 정보가 있다면 도움이 될 것입니다.

Expand All @@ -1155,6 +1178,7 @@
2A0A730C2B541A43004478C1 /* NetworkServiceType.swift in Sources */,
3C2F54522B51224500E7BF01 /* MyPageAccountInfoViewController.swift in Sources */,
3CE9C1352B4C4BC20086E4A3 /* CircleProgressbar.swift in Sources */,
3C4EDCCB2B58653800A9707C /* PostReplyResponseDTO.swift in Sources */,
2AF069B22B518F8E00CA3E48 /* MyPageNicknameEditView.swift in Sources */,
2FB64FF42B531A5C0082A414 /* WriteReplyView.swift in Sources */,
2FBBADF42B53BEB5002D6286 /* TransparentPopupViewController.swift in Sources */,
Expand Down
1 change: 1 addition & 0 deletions DontBe-iOS/DontBe-iOS/Global/Literals/ImageLiterals.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ enum ImageLiterals {

enum Home {
static var textLogo: UIImage { .load(name: "Logo") }
static var icnNotice: UIImage { .load(name: "icn_notice") }
}

enum Posting {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아래는 코드 패치입니다. 해당 패치에 대한 간단한 코드 리뷰를 도와드리겠습니다. 버그 위험 및 개선 제안은 환영합니다.

  • 이 코드 패치에는 심각한 버그나 위험이 보이지 않습니다.
  • "Home" 열거형에 "icnNotice"라는 UIImage 속성이 추가되었습니다. 문제가 없어 보입니다.

개선 제안:

  • 현재 코드 패치에서 큰 문제는 없어 보입니다. 하지만 몇 가지 개선 사항이 있을 수 있습니다. 이는 전체 코드 범위와 다른 파일/클래스에 따라 다를 수 있습니다.
  • 네이밍 컨벤션을 확인하여 통일성 있는 네이밍을 사용하는 것이 좋습니다. 예를 들어 "icnNotice" 대신 "noticeIcon"과 같은 네이밍을 고려할 수 있습니다.
  • Swift API 디자인 가이드라인을 따르면서, UIImage 로딩에 대한 옵셔널 처리나 오류 처리를 추가하는 것도 고려할 수 있습니다.

좀 더 자세한 코드 분석이 필요하다면 전체 코드 범위와 다른 파일/클래스에 대한 정보를 제공해주시면 됩니다.

Expand Down
1 change: 1 addition & 0 deletions DontBe-iOS/DontBe-iOS/Global/Literals/StringLiterals.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ enum StringLiterals {
enum Toast {
static let uploading = "게시 중..."
static let uploaded = "게시 완료!"
static let alreadyTransparency = "이미 투명도를 적용한 유저예요."
}

enum Notification {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

주어진 코드 패치에는 별다른 버그나 위험은 발견되지 않았습니다. 그러나 몇 가지 개선 제안이 있습니다:

  1. 문자열 리터럴을 열거형으로 관리하는 기능은 좋습니다. 하지만 이 경우, StringLiteralsToast, Notification은 독립된 두 개의 열거형으로 구성되어 있습니다. 열거형을 효율적으로 사용하려면 관련 있는 값들을 하나의 열거형으로 그룹화하는 것이 좋습니다.

  2. 문자열을 저장하기 위해 enum을 사용하는 대신 일반적인 struct를 사용해도 됩니다. 이 경우, 문자열 상수를 static let 대신 static var로 선언할 수 있습니다.

  3. 번역 가능한 문자열을 관리하는 방법도 고려해 볼 수 있습니다. 특히, uploadinguploaded와 같은 내용은 다국어 지원을 위해 로컬라이즈해야 할 수도 있습니다.

필요에 따라 이러한 제안들을 참고하여 코드 패치를 수정하는 것이 좋습니다.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "icn_notice.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "icn_notice@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "icn_notice@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

위의 코드 패치를 간단히 검토해 드리겠습니다.

이 코드는 JSON 형식으로 되어 있으며, "images" 배열 내에 이미지 파일 정보가 포함되어 있습니다. 각 이미지는 "filename" (파일 이름), "idiom" (용도), "scale" (배율) 속성을 가지고 있습니다. 이 속성들은 각각 이미지 파일의 이름, 일반적인 용도, 배율을 나타냅니다.

코드 자체에 버그나 위험이 없으며, 개선 제안 사항도 별다른 것이 없습니다. 이는 단순히 이미지 파일 정보를 담고 있는 JSON 데이터이기 때문에 수정할 필요가 없을 수 있습니다.

크게 문제가 있다거나 개선이 필요한 부분이 있다면 추가로 알려주세요.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// PostReplyResponseDTO.swift
// DontBe-iOS
//
// Created by 변상우 on 1/18/24.
//

import Foundation

// MARK: - PostReplyResponseDTO

struct PostReplyResponseDTO: Decodable {
let commentId: Int
let memberId: Int
let memberProfileUrl: String
let memberNickname: String
let isGhost: Bool
let memberGhost: Int
let isLiked: Bool
let commentLikedNumber: Int
let commentText: String
let time: String
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// PostTransparencyRequestDTO.swift
// DontBe-iOS
//
// Created by 변상우 on 1/18/24.
//

import Foundation

// MARK: - PostTransparencyRequestDTO

struct PostTransparencyRequestDTO: Encodable {
let alarmTriggerType: String
let targetMemberId: Int
let alarmTriggerId: Int
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 코드 패치는 PostTransparencyRequestDTO라는 구조체를 정의하고 있습니다. 이 구조체는 Encodable 프로토콜을 준수하며, alarmTriggerType, targetMemberId, alarmTriggerId라는 세 가지 속성을 갖고 있습니다.

이 코드에 현재 확인할 수 있는 버그나 위험이 없어 보입니다. 그러나 몇 가지 개선점이 있을 수 있습니다:

  1. 주석을 더욱 상세하게 작성하는 것이 도움이 됩니다. 예를 들어, 각 속성이 어떤 역할을 하는지, 사용되는 데이터 형식은 어떤지 설명할 수 있습니다.
  2. 속성 이름과 변수 이름에서 더욱 명확한 이름으로 변경할 수 있습니다. 읽기 쉬운 코드는 유지보수와 협업을 용이하게 만듭니다.
  3. 필요에 따라 속성들에 대한 유효성 검사를 추가할 수 있습니다. 예를 들어, targetMemberIdalarmTriggerId가 양수인지 확인하는 등의 체크를 할 수 있습니다.
  4. 일반적으로 Codable 프로토콜을 사용할 때, 커스텀한 인코딩 및 디코딩 로직이 필요한 경우에는 특별한 조치가 필요할 수 있습니다. 이러한 경우에는 CodingKey 프로토콜을 구현하거나, 커스텀 인코딩 및 디코딩 메서드를 추가할 수 있습니다.

그 외에는 현재 코드의 명료성과 안전성이 보존되며, 문제가 없어 보입니다.

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ final class HomeCollectionViewCell: UICollectionViewCell, UICollectionViewRegist
var LikeButtonAction: (() -> Void) = {}
var TransparentButtonAction: (() -> Void) = {}
var isLiked: Bool = false
var alarmTriggerType: String = ""
var targetMemberId: Int = 0
var alarmTriggerdId: Int = 0

// MARK: - UI Components

Expand Down Expand Up @@ -187,7 +190,7 @@ extension HomeCollectionViewCell {

func setLayout() {
backgroundUIView.snp.makeConstraints {
$0.edges.equalToSuperview()
$0.top.bottom.equalToSuperview()
$0.width.equalTo(UIScreen.main.bounds.width - 32)
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아래는 코드 패치입니다. 버그 위험 또는 개선 제안이 있는지 간단한 코드 리뷰를 도와드리겠습니다.

  1. alarmTriggerType, targetMemberId, alarmTriggerdId라는 변수가 추가되었습니다. 해당 변수들의 초기화 값은 적절한지 확인해야 합니다.
  2. backgroundUIView.snp.makeConstraints 부분에서 $0.edges.equalToSuperview() 대신 $0.top.bottom.equalToSuperview()로 수정되었습니다. 수정된 제약 조건이 의도한대로 동작하는지 확인해야 합니다.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,16 @@ final class HomeViewController: UIViewController {
let destinationViewController = PostViewController(viewModel: PostViewModel(networkProvider: NetworkService()))

var contentId: Int = 0
var alarmTriggerType: String = ""
var targetMemberId: Int = 0
var alarmTriggerdId: Int = 0

// MARK: - UI Components

private let myView = HomeView()
lazy var homeCollectionView = HomeCollectionView().collectionView
private var uploadToastView: DontBeToastView?
private var alreadyTransparencyToastView: DontBeToastView?

// MARK: - Life Cycles

Expand Down Expand Up @@ -135,6 +139,7 @@ extension HomeViewController {
private func setDelegate() {
homeCollectionView.dataSource = self
homeCollectionView.delegate = self
transparentPopupVC.transparentButtonPopupView.delegate = self
}

private func setNotification() {
Expand Down Expand Up @@ -210,6 +215,33 @@ extension HomeViewController {
}
}
}

func showAlreadyTransparencyToast() {
DispatchQueue.main.async {
self.alreadyTransparencyToastView = DontBeToastView()
self.alreadyTransparencyToastView?.toastLabel.text = StringLiterals.Toast.alreadyTransparency
self.alreadyTransparencyToastView?.circleProgressBar.alpha = 0
self.alreadyTransparencyToastView?.checkImageView.alpha = 1
self.alreadyTransparencyToastView?.checkImageView.image = ImageLiterals.Home.icnNotice
self.alreadyTransparencyToastView?.container.backgroundColor = .donPrimary

self.view.addSubviews(self.alreadyTransparencyToastView ?? DontBeToastView())

self.alreadyTransparencyToastView?.snp.makeConstraints {
$0.leading.trailing.equalToSuperview().inset(16.adjusted)
$0.bottom.equalTo(self.tabBarHeight.adjusted).inset(6.adjusted)
$0.height.equalTo(44.adjusted)
}

UIView.animate(withDuration: 1.5, delay: 1, options: .curveEaseIn) {
self.alreadyTransparencyToastView?.alpha = 0
}

DispatchQueue.main.asyncAfter(deadline: .now() + 2.5) {
self.alreadyTransparencyToastView?.removeFromSuperview()
}
}
}
}

// MARK: - Network
Expand Down Expand Up @@ -246,25 +278,27 @@ extension HomeViewController: UICollectionViewDataSource, UICollectionViewDelega
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell =
HomeCollectionViewCell.dequeueReusableCell(collectionView: collectionView, indexPath: indexPath)
cell.alarmTriggerType = "contentGhost"
cell.targetMemberId = viewModel.postData[indexPath.row].memberId
cell.alarmTriggerdId = viewModel.postData[indexPath.row].contentId
if viewModel.postData[indexPath.row].memberId == loadUserData()?.memberId {
cell.ghostButton.isHidden = true
cell.verticalTextBarView.isHidden = true
cell.KebabButtonAction = {
self.deleteBottomsheet.showSettings()
}
} else {
cell.ghostButton.isHidden = false
cell.verticalTextBarView.isHidden = false
cell.KebabButtonAction = {
self.deleteBottomsheet.showSettings()
}
}
cell.KebabButtonAction = {
self.deleteBottomsheet.showSettings()
}
cell.LikeButtonAction = {
cell.isLiked.toggle()
cell.likeButton.setImage(cell.isLiked ? ImageLiterals.Posting.btnFavoriteActive : ImageLiterals.Posting.btnFavoriteInActive, for: .normal)
}
cell.TransparentButtonAction = {
// present
self.alarmTriggerType = cell.alarmTriggerType
self.targetMemberId = cell.targetMemberId
self.alarmTriggerdId = cell.alarmTriggerdId
self.present(self.transparentPopupVC, animated: false, completion: nil)
}
cell.nicknameLabel.text = viewModel.postData[indexPath.row].memberNickname
Expand Down Expand Up @@ -295,3 +329,29 @@ extension HomeViewController: UICollectionViewDataSource, UICollectionViewDelega
return CGSize(width: UIScreen.main.bounds.width, height: 24.adjusted)
}
}

extension HomeViewController: DontBePopupDelegate {
func cancleButtonTapped() {
self.dismiss(animated: false)
}

func confirmButtonTapped() {
self.dismiss(animated: false)
Task {
do {
if let accessToken = KeychainWrapper.loadToken(forKey: "accessToken") {
let result = try await self.viewModel.postDownTransparency(accessToken: accessToken,
alarmTriggerType: self.alarmTriggerType,
targetMemberId: self.targetMemberId,
alarmTriggerId: self.alarmTriggerdId)
if result?.status == 400 {
// 이미 투명도를 누른 대상인 경우, 토스트 메시지 보여주기
showAlreadyTransparencyToast()
}
}
} catch {
print(error)
}
}
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아래는 코드 패치에 대한 간략한 코드 리뷰입니다. 버그 위험 또는 개선 제안 사항을 환영합니다:

  1. alarmTriggerType, targetMemberId, alarmTriggerdId 변수를 초기화하지 않았으며, 사용되기 전에 값을 할당해야 합니다.
  2. showAlreadyTransparencyToast() 메서드에서 애니메이션의 지연 시간과 다음 조치를 실행하기 전에 해당 ToastView를 삭제하는 대기 시간을 확인하십시오.
  3. setDelegate() 메서드에서 transparentPopupVC.transparentButtonPopupView.delegate를 설정하기 전에 해당 뷰가 초기화되었는지 확인하십시오.
  4. cell.KebabButtonAction 클로저와 cell.TransparentButtonAction 클로저에서 동일한 코드가 중복됩니다. 코드 중복을 방지하고 유지 보수성을 향상시키기 위해 중복 코드를 추출하여 재사용할 수 있는 독립적인 함수로 만드는 것이 좋습니다.
  5. DontBePopupDelegate 프로토콜의 confirmButtonTapped() 메서드에서 이스케이프 비동기 작업을 사용하고 있습니다. 이 경우 await 키워드와 함께 사용받은 표현식을 Task { } 블록 안으로 이동시켜야 합니다.

위의 사항들을 고려하여 코드를 개선할 수 있습니다.

Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,13 @@ final class HomeViewModel: ViewModelType {

extension HomeViewModel {
private func getPostDataAPI(accessToken: String) async throws -> BaseResponse<[PostDataResponseDTO]>? {
let accessToken = accessToken
do {
let result: BaseResponse<[PostDataResponseDTO]>? = try
await self.networkProvider.donNetwork(type: .get, baseURL: Config.baseURL + "/content/all", accessToken: accessToken, body: EmptyBody(), pathVariables: ["":""])
let result: BaseResponse<[PostDataResponseDTO]>? = try await
self.networkProvider.donNetwork(type: .get,
baseURL: Config.baseURL + "/content/all",
accessToken: accessToken,
body: EmptyBody(),
pathVariables: ["":""])

if let data = result?.data {
var tempArrayData: [PostDataResponseDTO] = []
Expand All @@ -80,4 +83,22 @@ extension HomeViewModel {
return nil
}
}

func postDownTransparency(accessToken: String, alarmTriggerType: String, targetMemberId: Int, alarmTriggerId: Int) async throws -> BaseResponse<EmptyResponse>? {
do {
let result: BaseResponse<EmptyResponse>? = try await
self.networkProvider.donNetwork(type: .post,
baseURL: Config.baseURL + "/ghost",
accessToken: accessToken,
body: PostTransparencyRequestDTO(
alarmTriggerType: alarmTriggerType,
targetMemberId: targetMemberId,
alarmTriggerId: alarmTriggerId
),
pathVariables: ["":""])
return result
} catch {
return nil
}
}
}
Loading