-
Notifications
You must be signed in to change notification settings - Fork 0
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
chore: 각종 문제점 개선 #293
chore: 각종 문제점 개선 #293
Changes from all commits
8bc4b51
b2de182
978fe3f
01c9c44
e12b1ee
c534c20
dadd264
ac950c1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,8 @@ protocol PlaybackBusinessLogic { | |
func moveToTagPlay(with request: PlaybackModels.MoveToRelativeView.Request) | ||
@discardableResult | ||
func fetchPosts() -> Task<Bool, Never> | ||
@discardableResult | ||
func loadProfileImageAndLocation(with request: PlaybackModels.LoadProfileImageAndLocation.Request) -> Task<Bool, Never> | ||
} | ||
|
||
protocol PlaybackDataStore: AnyObject { | ||
|
@@ -84,7 +86,7 @@ final class PlaybackInteractor: PlaybackBusinessLogic, PlaybackDataStore { | |
posts = worker.makeInfiniteScroll(posts: posts) | ||
self.posts = posts | ||
} | ||
let videos: [Models.PlaybackVideo] = await transPostToVideo(posts) | ||
let videos: [Models.PlaybackVideo] = transPostToVideo(posts) | ||
let response: Models.LoadPlaybackVideoList.Response = Models.LoadPlaybackVideoList.Response(videos: videos) | ||
await MainActor.run { | ||
presenter?.presentVideoList(with: response) | ||
|
@@ -251,25 +253,23 @@ final class PlaybackInteractor: PlaybackBusinessLogic, PlaybackDataStore { | |
previousCell.playbackView.playPlayer() | ||
} | ||
|
||
private func transPostToVideo(_ posts: [Post]) async -> [Models.PlaybackVideo] { | ||
return await posts.asyncCompactMap { post in | ||
private func transPostToVideo(_ posts: [Post]) -> [Models.PlaybackVideo] { | ||
return posts.compactMap { post in | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이제 여기서 이미지 로드를 기다리지 않아도 되어서 확실히 성능 향상이 있을 것 같네요 |
||
guard let videoURL: URL = post.board.videoURL else { return nil } | ||
async let profileImageData = self.worker?.fetchImageData(with: post.member.profileImageURL) | ||
async let thumbnailImageData = self.worker?.fetchImageData(with: post.board.thumbnailImageURL) | ||
async let location = self.worker?.transLocation(latitude: post.board.latitude, longitude: post.board.longitude) | ||
return Models.PlaybackVideo(displayPost: Models.DisplayedPost( | ||
member: Models.Member( | ||
memberID: post.member.identifier, | ||
username: post.member.username, | ||
profileImageData: await profileImageData), | ||
board: Models.Board( | ||
boardID: post.board.identifier, | ||
title: post.board.title, | ||
description: post.board.description, | ||
thumbnailImageData: await thumbnailImageData, | ||
videoURL: videoURL, | ||
location: await location), | ||
tags: post.tag)) | ||
return Models.PlaybackVideo( | ||
displayedPost: Models.DisplayedPost( | ||
member: Models.Member( | ||
memberID: post.member.identifier, | ||
username: post.member.username, | ||
profileImageURL: post.member.profileImageURL), | ||
board: Models.Board( | ||
boardID: post.board.identifier, | ||
title: post.board.title, | ||
description: post.board.description, | ||
videoURL: videoURL, | ||
latitude: post.board.latitude, | ||
longitude: post.board.longitude), | ||
tags: post.tag)) | ||
} | ||
} | ||
|
||
|
@@ -314,7 +314,7 @@ final class PlaybackInteractor: PlaybackBusinessLogic, PlaybackDataStore { | |
} | ||
guard let newPosts else { return false } | ||
self.posts?.append(contentsOf: newPosts) | ||
let videos: [Models.PlaybackVideo] = await transPostToVideo(newPosts) | ||
let videos: [Models.PlaybackVideo] = transPostToVideo(newPosts) | ||
let response: Models.LoadPlaybackVideoList.Response = Models.LoadPlaybackVideoList.Response(videos: videos) | ||
await MainActor.run { | ||
presenter?.presentLoadFetchVideos(with: response) | ||
|
@@ -325,4 +325,17 @@ final class PlaybackInteractor: PlaybackBusinessLogic, PlaybackDataStore { | |
return false | ||
} | ||
} | ||
|
||
func loadProfileImageAndLocation(with request: PlaybackModels.LoadProfileImageAndLocation.Request) -> Task<Bool, Never> { | ||
Task { | ||
async let profileImageData = self.worker?.fetchImageData(with: request.profileImageURL) | ||
async let location: String? = self.worker?.transLocation(latitude: request.latitude, longitude: request.longitude) | ||
Comment on lines
+331
to
+332
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍👍 |
||
let response: Models.LoadProfileImageAndLocation.Response = Models.LoadProfileImageAndLocation.Response(curCell: request.curCell, profileImageData: await profileImageData, location: await location) | ||
await MainActor.run { | ||
presenter?.presentLoadProfileImageAndLocation(with: response) | ||
return true | ||
} | ||
return false | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,9 +48,10 @@ final class PlaybackView: UIView { | |
let button: UIButton = UIButton() | ||
button.layer.cornerRadius = 19 | ||
button.layer.borderWidth = 1 | ||
button.layer.borderColor = UIColor.layoverWhite.cgColor | ||
button.layer.borderColor = UIColor.grey400.cgColor | ||
button.backgroundColor = .layoverWhite | ||
button.clipsToBounds = true | ||
button.imageView?.contentMode = .scaleAspectFill | ||
return button | ||
}() | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 그.. 이 이슈랑 관련된건 아니긴한데 playbackView 내부 Profile 버튼의 borderColor를 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 흰색이 좀 튀는 너낌 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. UIButton이 아니라 Button의 이미지의 border컬러가 맞을까요? |
||
|
@@ -65,6 +66,7 @@ final class PlaybackView: UIView { | |
private let locationLabel: UILabel = { | ||
let label: UILabel = UILabel() | ||
label.font = .loFont(type: .body2) | ||
label.text = "이름 모를 곳에서" | ||
label.textColor = UIColor.layoverWhite | ||
return label | ||
}() | ||
|
@@ -201,8 +203,8 @@ final class PlaybackView: UIView { | |
} | ||
} | ||
|
||
func setProfileButton(member: PlaybackModels.Member) { | ||
if let imageData: Data = member.profileImageData { | ||
func setProfileButton(imageData: Data?) { | ||
if let imageData { | ||
profileButton.setImage(UIImage(data: imageData), for: .normal) | ||
} else { | ||
profileButton.setImage(UIImage.profile, for: .normal) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ protocol PlaybackDisplayLogic: AnyObject { | |
func deleteVideo(viewModel: PlaybackModels.DeletePlaybackVideo.ViewModel) | ||
func routeToProfile() | ||
func routeToTagPlay() | ||
func setProfileImageAndLocation(viewModel: PlaybackModels.LoadProfileImageAndLocation.ViewModel) | ||
} | ||
|
||
final class PlaybackViewController: BaseViewController { | ||
|
@@ -244,14 +245,20 @@ extension PlaybackViewController: PlaybackDisplayLogic { | |
playbackCollectionView.register(PlaybackCell.self, forCellWithReuseIdentifier: PlaybackCell.identifier) | ||
dataSource = UICollectionViewDiffableDataSource<Section, Models.PlaybackVideo>(collectionView: playbackCollectionView) { (collectionView, indexPath, playbackVideo) -> UICollectionViewCell? in | ||
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: PlaybackCell.identifier, for: indexPath) as? PlaybackCell else { return PlaybackCell() } | ||
cell.setPlaybackContents(post: playbackVideo.displayPost) | ||
cell.setPlaybackContents(post: playbackVideo.displayedPost) | ||
if let teleportIndex = viewModel.teleportIndex { | ||
if indexPath.row == 0 || indexPath.row == teleportIndex { | ||
cell.playbackView.resetPlayer() | ||
return cell | ||
} | ||
} | ||
cell.addAVPlayer(url: playbackVideo.displayedPost.board.videoURL) | ||
self.interactor?.loadProfileImageAndLocation(with: Models.LoadProfileImageAndLocation.Request( | ||
curCell: cell, | ||
profileImageURL: playbackVideo.displayedPost.member.profileImageURL, | ||
latitude: playbackVideo.displayedPost.board.latitude, | ||
longitude: playbackVideo.displayedPost.board.longitude)) | ||
Comment on lines
+256
to
+260
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 오 확실히 이렇게 필요한 부분에서만 호출되어서 로드되면 모든 데이터를 기다리지 않게 되겠네요 |
||
cell.delegate = self | ||
cell.addAVPlayer(url: playbackVideo.displayPost.board.videoURL) | ||
return cell | ||
} | ||
} | ||
|
@@ -298,6 +305,10 @@ extension PlaybackViewController: PlaybackDisplayLogic { | |
func routeToTagPlay() { | ||
router?.routeToTagPlay() | ||
} | ||
|
||
func setProfileImageAndLocation(viewModel: PlaybackModels.LoadProfileImageAndLocation.ViewModel) { | ||
viewModel.curCell.setProfileImageAndLocation(imageData: viewModel.profileImageData, location: viewModel.location) | ||
} | ||
} | ||
|
||
extension PlaybackViewController: UICollectionViewDelegateFlowLayout { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,7 +60,7 @@ final class ProfileInteractor: ProfileBusinessLogic, ProfileDataStore { | |
guard let userProfile = await userWorker?.fetchProfile(by: profileId) else { | ||
return false | ||
} | ||
|
||
posts = [] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 놓친 부분 찾아주셔서 감사합니다. |
||
nickname = userProfile.username | ||
introduce = userProfile.introduce | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍👍👍👍