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

서버에서 바뀐 업로드 과정 반영 #237

Merged
merged 8 commits into from
Nov 30, 2023
Merged

Conversation

youlalala
Copy link
Member

Issue

Overview

  • 서버에서 바뀐 업로드 과정 반영 (Presigned Url 관련 작업 제거)
  • isUploading : post music 할 때 인코딩 작업이 이루어지므로, 이 상태도 isLoading 상태에 추가했습니다.
    isLoading (progress bar) -> image file, audio file, isUploading 상태에 따라 변함
  • isUploadEnable : 기존 isUploadedEnable 에다가 업로드 중인 상황에는 버튼을 클릭하지 못하도록 상태를 바꿔주었습니다.
    isUploadEnable (완료버튼) -> musicTitle, musicGenre, image Url, audio Url 가 모두 들어왔을 때 업로드 가능 + 업로드 중일 때는 업로드 불가

Screenshot

default.mp4

@youlalala youlalala added ✨ feat 기능 개발 🤖 android android labels Nov 30, 2023
@youlalala youlalala added this to the 🆙 upload milestone Nov 30, 2023
@youlalala youlalala self-assigned this Nov 30, 2023
@youlalala youlalala linked an issue Nov 30, 2023 that may be closed by this pull request
Copy link

github-actions bot commented Nov 30, 2023

Test Results

4 tests   4 ✔️  1s ⏱️
1 suites  0 💤
1 files    0

Results for commit 1fcd48f.

♻️ This comment has been updated with latest results.

Copy link
Collaborator

@2taezeat 2taezeat left a comment

Choose a reason for hiding this comment

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

고생하셨습니다~

Comment on lines 18 to 32
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(),
)
Copy link
Member

Choose a reason for hiding this comment

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

함수 이름은 get인데 실제 동작은 사이드 이펙트가 있는 거 같아서 해석하기 어려웠어

Copy link
Member Author

Choose a reason for hiding this comment

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

반영완료~

Comment on lines 16 to 22
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()
}
Copy link
Member

Choose a reason for hiding this comment

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

코드에 대한 코멘트는 아님!
uuid를 가져오는 API가 서버에서 사이드 이펙트가 일어나지 않는다면, 네트워킹을 두 번 해서 업로드하기보다는 클라이언트쪽에서 uuid를 생성하는 방식을 사용하는 건 어떨지 서버와 논의해 봐야 할 듯

Copy link
Member

@HamBP HamBP Nov 30, 2023

Choose a reason for hiding this comment

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

코드를 해석하기 어려운 것 같아

  1. isLoading, isUploading, isUploadEnable 이 각각 어떤 차이가 있는지 확인하기 어렵다.
  2. isUploadEnable 의 상태는 combine에서만 처리할 것 같지만, 실제로는 변경하는 곳이 여러 곳이다.

Copy link
Member Author

Choose a reason for hiding this comment

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

isUpladEnable 상태를 한곳에서만 처리하도록 변경하였습니당!

Copy link
Member Author

@youlalala youlalala Nov 30, 2023

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
Copy link
Member

Choose a reason for hiding this comment

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

제목과 장르를 입력하지 않아도 업로드가 가능한 걸까?

Copy link
Member Author

Choose a reason for hiding this comment

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

제목과 장르가 입력되지 않으면 애초에 uploadAudio 함수를 실행시킬 수 없엉

Copy link
Member

Choose a reason for hiding this comment

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

그럼 업로드 도중 제목을 지우면 어떻게 될까?

Copy link
Member Author

Choose a reason for hiding this comment

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

그건 musicTitle을 옵저빙 하고 있기 때문에 false 로 바뀌지

Copy link
Member Author

Choose a reason for hiding this comment

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

제가 착각했습니당! ㅠㅠㅠㅠㅠ 근데 리팩토링하면서 && 처리를 통해 이부분도 가능하도록 바꿨습니다!

Copy link
Member

@HamBP HamBP left a comment

Choose a reason for hiding this comment

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

UploadViewModel 부분 정리가 필요해 보여

@youlalala youlalala requested a review from HamBP November 30, 2023 10:15
Comment on lines 120 to 135
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)
}
}
Copy link
Member

@HamBP HamBP Nov 30, 2023

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() {
// ...

Copy link
Member Author

Choose a reason for hiding this comment

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

반영완료!! 👏🏻

Copy link
Member

@HamBP HamBP left a comment

Choose a reason for hiding this comment

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

LGTM!!
고생했어용

@youlalala youlalala merged commit 6998ed2 into develop Nov 30, 2023
2 checks passed
@youlalala youlalala deleted the android/feature/227 branch November 30, 2023 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖 android android ✨ feat 기능 개발
Projects
None yet
Development

Successfully merging this pull request may close these issues.

바뀐 업로드 과정 반영
3 participants