-
Notifications
You must be signed in to change notification settings - Fork 1
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
서버에서 바뀐 업로드 과정 반영 #237
서버에서 바뀐 업로드 과정 반영 #237
Conversation
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.
고생하셨습니다~
override fun getCoverImageUrl(uuid: String, file: File): Flow<String> = flow { | ||
val urlResponse = uploadApi.postImage( | ||
image = file.toImageMultipart(), | ||
uuid = uuid.toRequestBody(), | ||
type = "cover".toRequestBody(), | ||
) | ||
emit(urlResponse.url) | ||
} | ||
|
||
override fun getAudioUrl(file: File): Flow<String> = flow { | ||
val urlResponse = uploadApi.postMusic(file.toMultipart("audio/mpeg")) | ||
override fun getAudioUrl(uuid: String, file: File): Flow<String> = flow { | ||
val urlResponse = | ||
uploadApi.postMusic( | ||
audio = file.toAudioMultipart(), | ||
uuid = uuid.toRequestBody(), | ||
) |
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.
함수 이름은 get인데 실제 동작은 사이드 이펙트가 있는 거 같아서 해석하기 어려웠어
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.
반영완료~
fun uploadAudio(audioFile: File): Flow<String> = uuidRepository.getUuid().map { uuid -> | ||
urlRepository.getAudioUrl(uuid, audioFile).first() | ||
} | ||
|
||
fun uploadMusicCover(imageFile: File): Flow<String> = uuidRepository.getUuid().map { uuid -> | ||
urlRepository.getCoverImageUrl(uuid, imageFile).first() | ||
} |
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.
코드에 대한 코멘트는 아님!
uuid를 가져오는 API가 서버에서 사이드 이펙트가 일어나지 않는다면, 네트워킹을 두 번 해서 업로드하기보다는 클라이언트쪽에서 uuid를 생성하는 방식을 사용하는 건 어떨지 서버와 논의해 봐야 할 듯
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.
코드를 해석하기 어려운 것 같아
- isLoading, isUploading, isUploadEnable 이 각각 어떤 차이가 있는지 확인하기 어렵다.
- isUploadEnable 의 상태는 combine에서만 처리할 것 같지만, 실제로는 변경하는 곳이 여러 곳이다.
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.
isUpladEnable 상태를 한곳에서만 처리하도록 변경하였습니당!
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.
isUploading 변수를 encoding 으로 바꿔서 더 코드를 해석하기 쉽도록 바꿨어!
isLoading-Progress Bar 상태,
isUploadEnable-완료 Button 활성화/비활성화 유무
라고 생각하면돼
_events.emit(UploadEvent.NavigateToBack) | ||
}.onCompletion { | ||
_isUploadEnable.value = true |
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.
제목과 장르를 입력하지 않아도 업로드가 가능한 걸까?
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.
제목과 장르가 입력되지 않으면 애초에 uploadAudio 함수를 실행시킬 수 없엉
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.
그럼 업로드 도중 제목을 지우면 어떻게 될까?
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.
그건 musicTitle을 옵저빙 하고 있기 때문에 false 로 바뀌지
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.
제가 착각했습니당! ㅠㅠㅠㅠㅠ 근데 리팩토링하면서 && 처리를 통해 이부분도 가능하도록 바꿨습니다!
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.
UploadViewModel 부분 정리가 필요해 보여
16966b1
to
23ce67d
Compare
2c76356
to
4a37a34
Compare
acef177
to
d2627cf
Compare
fun uploadMusic() { | ||
if (isUploadEnable.value) { | ||
if (uiState.value.isUploadEnable) { | ||
uploadMusicUseCase( | ||
imageUrl = imageState.value.url, | ||
audioUrl = audioState.value.url, | ||
title = musicTitle.value, | ||
genre = musicGenre.value | ||
).onEach { | ||
imageUrl = uiState.value.imageState.url, | ||
audioUrl = uiState.value.audioState.url, | ||
title = uiState.value.musicTitle, | ||
genre = uiState.value.musicGenre | ||
).onStart { | ||
_uiState.update { it.copy(encoding = true) } | ||
}.onEach { | ||
_events.emit(UploadEvent.NavigateToBack) | ||
}.onCompletion { | ||
_uiState.update { it.copy(encoding = false) } | ||
}.launchIn(viewModelScopeWithExceptionHandler) | ||
} | ||
} |
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.
early return 이용하면 좀 더 깔끔할 거 같긴 합니당
if (!uiState.value.isUploadEnable) return
uplopadMusicUseCase() {
// ...
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.
반영완료!! 👏🏻
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.
LGTM!!
고생했어용
Issue
Overview
isLoading (progress bar) -> image file, audio file, isUploading 상태에 따라 변함
isUploadEnable (완료버튼) -> musicTitle, musicGenre, image Url, audio Url 가 모두 들어왔을 때 업로드 가능 + 업로드 중일 때는 업로드 불가
Screenshot
default.mp4