Skip to content

Commit

Permalink
[Feat] Keyneez#46 - ContentRepository 저장탭 함수 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
kpk0616 committed Jan 13, 2023
1 parent 6a8b674 commit 6593fb2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Keyneez/Keyneez/Tab/Home/ContentRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ protocol ContentRepository {
func getAllContents(token: String, completion: @escaping([HomeContentResponseDto]) -> Void)
func getDetailContent(token: String, contentId: Int, completion: @escaping(ContentDetailResponseDto) -> Void)
func getSearchContent(token: String, keyword: String, completion: @escaping([SearchContentResponseDto]) -> Void)
func getLikedContent(token: String, completion: @escaping([LikeContentResponseDto]) -> Void)
}

final class KeyneezContentRepository: ContentRepository {
Expand Down Expand Up @@ -50,4 +51,16 @@ final class KeyneezContentRepository: ContentRepository {
}
}
}

func getLikedContent(token: String, completion: @escaping ([LikeContentResponseDto]) -> Void) {
ContentAPIProvider.shared.getLikedContent(token: token) { result in
switch result {
case .success(let data):
guard let likedContentList = data else { return }
completion(likedContentList)
case .failure(let failure):
print("fail")
}
}
}
}
13 changes: 13 additions & 0 deletions Keyneez/Keyneez/Tab/Like/LikeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import UIKit

final class LikeViewController: NiblessViewController, NavigationBarProtocol {
let repository: ContentRepository = KeyneezContentRepository()

lazy var navigationView: UIView = NavigationViewBuilder(barViews: [.button(with: myLikeButton), .flexibleBox, .iconButton(with: editButton)]).build()
private lazy var myLikeButton: UIButton = .init(primaryAction: touchUpMyLikeButton).then {
$0.setTitle("저장", for: .normal)
Expand Down Expand Up @@ -52,6 +54,17 @@ final class LikeViewController: NiblessViewController, NavigationBarProtocol {
register()
addNavigationViewToSubview()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
guard let token = UserSession.shared.accessToken else { return }
repository.get(token: token, keyword: keyword!) {
[weak self] arr in
guard let self else {return}
self.searchDatasource = arr
self.setSearchResultCountingLabel(count: searchDatasource.count)
DispatchQueue.main.async {
self.homeSearchCollectionView.reloadData()
}
}

extension LikeViewController {
Expand Down

0 comments on commit 6593fb2

Please sign in to comment.