-
Notifications
You must be signed in to change notification settings - Fork 2
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
커뮤니티 게시글 작성 및 수정 기능 #69
Conversation
app/src/main/java/com/wafflestudio/siksha2/network/SikshaApi.kt
Outdated
Show resolved
Hide resolved
b1310ce
to
a010501
Compare
app/src/main/java/com/wafflestudio/siksha2/compose/ui/community/PostCreateScreen.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/wafflestudio/siksha2/ui/main/community/PostCreateViewModel.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/wafflestudio/siksha2/compose/ui/community/PostCreateScreen.kt
Outdated
Show resolved
Hide resolved
@@ -10,6 +10,7 @@ object SikshaColors { | |||
val Black900 = Color(0xFF000000) | |||
|
|||
val Gray800 = Color(0xFF393939) | |||
val Gray700 = Color(0xFF575757) |
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.
색 쓰려는데 없어서 대충 추가함... 디자인 QA 때 같이 보자
app/src/main/java/com/wafflestudio/siksha2/ui/main/community/PostCreateViewModel.kt
Outdated
Show resolved
Hide resolved
98feff8
to
7f0580b
Compare
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.
수고많았어~~~!!!
app/src/main/java/com/wafflestudio/siksha2/ui/main/community/PostCreateFragment.kt
Show resolved
Hide resolved
app/src/main/java/com/wafflestudio/siksha2/compose/ui/community/PostCreateScreen.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/wafflestudio/siksha2/compose/ui/community/PostCreateScreen.kt
Show resolved
Hide resolved
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.
큼직한 컴포저블 별로 @Preview 좀만 넣어줘
컴포즈 코드만 보고 어케생긴 UI를 그리는건지 알기어려워서
_board.value = communityRepository.getBoard(post.value.boardId) | ||
_title.value = post.value.title | ||
_content.value = post.value.content | ||
_imageUriList.value = post.value.etc?.images?.map { Uri.parse(it) } ?: listOf() |
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.
image url을 Uri로 파싱하는 이유가 있어? edit 시에도 create와 마찬가지로 imageUriList: StateFlow<List<Uri>>
를 사용하기 위함?
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.
엉 imageUriList는 이미지 추가할 때마다 uri로 관리하는데 서버에서는 기존 이미지 url을 string으로 내려 주니까 받을 때 파싱해 주고 있어
app/src/main/java/com/wafflestudio/siksha2/ui/main/community/PostCreateViewModel.kt
Outdated
Show resolved
Hide resolved
val imageList = _imageUriList.value.map { uri -> | ||
if (_imageFileList.value.containsKey(uri.toString())) { | ||
val filename = uri.toString() | ||
byteArrayToMultipartBody(filename, _imageFileList.value.getValue(filename)) | ||
} else { | ||
getCompressedImageAsMultipartBody(context, uri) | ||
} | ||
} |
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.
imageList는 유저가 새로 추가한 이미지의 Uri
+ 기존 이미지의 https url을 파싱하여 얻은 Uri
이고
imageFileList는 기존 이미지의 https url
to 기존 이미지의 https url로부터 다운받은 bytearray
map인거지?
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.
엉 맞아 그래서 imageFileList(이제 리팩터링해서 downloadedImages)는 초기화 후에는 안 바뀜
_post도 수정 전 게시물 내용을 저장하는 용도라서 초기화 이후에는 안 바뀜
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.
ㅇㅎㅇㅎ 오키 그럼 post랑 imageFileList는 StateFlow일 필요 없겠네
StateFlow는 다른 객체로 바뀌는 걸 감지하기 위해서 쓰는거니까
일단 이렇게하고 담에 develop에서 바꿔줘
fun deleteImageUri(index: Int) { | ||
val uriList = _imageUriList.value.toMutableList() | ||
if (index < uriList.size) { | ||
uriList.removeAt(index) | ||
_imageUriList.value = uriList | ||
} | ||
} |
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.
여기서 imageFileList는 안건드는 이유는, imageUriList에서 없애기만 해도 patchPost()할 때 해당 이미지가 제외되기 때문인거지?
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.
맞아맞아
뷰모델 내 프라퍼티들이 전체적으로 '원 글의 정보'와 '새로 쏠 정보'로 구분되어 있어
순서 조절해서 주석으로 달아 놓을게
app/src/main/java/com/wafflestudio/siksha2/ui/main/community/PostCreateViewModel.kt
Outdated
Show resolved
Hide resolved
@POST("/community/posts") | ||
suspend fun postCreatePost( | ||
@Part("board_id") boardId: Long, | ||
@Part title: MultipartBody.Part, |
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.
나도 String은 이렇게 안하면 계속 "가 붙어서 이렇게 했는데 같은 이유야?
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.
고생많았다진짜루
No description provided.