Skip to content

Commit

Permalink
Merge pull request #288 from School-of-Company/feature/#287_delete_pa…
Browse files Browse the repository at this point in the history
…tch_post

🔀 :: (#287) Delete Feature Patch Post
  • Loading branch information
Chaejongin12 committed Sep 1, 2024
2 parents c5bf5aa + f189b00 commit 51d8dcd
Show file tree
Hide file tree
Showing 11 changed files with 2 additions and 96 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ fun BitgoeulNavHost(
onItemClick = navController::navigateToPostDetailPage,
)
postDetailScreen(
// onEditClicked = navController::navigateToPostAddPage,
onDeleteClicked = navController::navigateUp,
onBackClicked = navController::navigateUp
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ import java.util.UUID
interface PostRepository {
fun getPostList(type: FeedType, size: Int, page: Int): Flow<GetPostListEntity>
fun getDetailPost(id: UUID): Flow<GetDetailPostEntity>
// fun editPost(id: UUID, body: WritePostParam): Flow<Unit>
fun deletePost(id: UUID): Flow<Unit>
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,6 @@ class PostRepositoryImpl @Inject constructor(
}
}

// override fun editPost(id: UUID, body: WritePostParam): Flow<Unit> {
// return postDataSource.editPost(
// id = id,
// body = body.toRequest()
// )
// }

override fun deletePost(id: UUID): Flow<Unit> {
return postDataSource.deletePost(id = id)
}
Expand Down

This file was deleted.

9 changes: 0 additions & 9 deletions core/network/src/main/java/com/msg/network/api/PostAPI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@ package com.msg.network.api
import com.msg.model.enumdata.FeedType
import com.msg.network.response.post.GetDetailPostResponse
import com.msg.network.response.post.GetPostListResponse
import retrofit2.http.Body
import retrofit2.http.DELETE
import retrofit2.http.GET
import retrofit2.http.PATCH
import retrofit2.http.POST
import retrofit2.http.Path
import retrofit2.http.Query
import java.util.UUID
Expand All @@ -25,12 +22,6 @@ interface PostAPI {
@Path("id") id: UUID
): GetDetailPostResponse

// @PATCH("post/{id}")
// suspend fun editPost(
// @Path("id") id: UUID,
// @Body body: WritePostRequest
// )

@DELETE("post/{id}")
suspend fun deletePost(
@Path("id") id: UUID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ import java.util.UUID
interface PostDataSource {
fun getPostList(type: FeedType, size: Int, page: Int): Flow<GetPostListResponse>
fun getDetailPost(id: UUID): Flow<GetDetailPostResponse>
// fun editPost(id: UUID, body: WritePostRequest): Flow<Unit>
fun deletePost(id: UUID): Flow<Unit>
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ class PostDataSourceImpl @Inject constructor(
override fun getDetailPost(id: UUID): Flow<GetDetailPostResponse> =
makeRequest { postAPI.getDetailPost(id = id) }

// override fun editPost(id: UUID, body: WritePostRequest): Flow<Unit> =
// makeRequest { postAPI.editPost(id = id, body = body) }

override fun deletePost(id: UUID): Flow<Unit> =
makeRequest { postAPI.deletePost(id = id) }
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class LectureViewModel @Inject constructor(
private val _getTakingLectureStudentListResponse = MutableStateFlow<Event<GetTakingLectureStudentListEntity>>(Event.Loading)
val getTakingLectureStudentListResponse = _getTakingLectureStudentListResponse.asStateFlow()

// 네이밍을 editPostResponse에서 editLectureCourseCompletionStatusResponse로 변경해야함
private val _editPostResponse = MutableStateFlow<Event<Unit>>(Event.Loading)
val editPostResponse = _editPostResponse.asStateFlow()

Expand Down
17 changes: 0 additions & 17 deletions feature/post/src/main/java/com/msg/post/PostDetailScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ import java.util.UUID
@Composable
internal fun PostDetailScreenRoute(
viewModel: PostViewModel = hiltViewModel(LocalContext.current as ComponentActivity),
// onEditClicked: () -> Unit,
onDeleteClicked: () -> Unit,
onBackClicked: () -> Unit
) {
Expand All @@ -69,10 +68,6 @@ internal fun PostDetailScreenRoute(
onDeleteClicked()
viewModel.deletePost(it)
},
// onEditClicked = {
// onEditClicked()
// viewModel.getFilledEditPage()
// },
onBackClicked = {
onBackClicked()
viewModel.selectedId.value = UUID.randomUUID()
Expand Down Expand Up @@ -102,7 +97,6 @@ internal fun PostDetailScreen(
id: UUID,
role: Authority = Authority.ROLE_USER,
onDeleteClicked: (UUID) -> Unit,
// onEditClicked: () -> Unit,
onBackClicked: () -> Unit
) {
val (isDialogShow, setIsDialogShow) = rememberSaveable { mutableStateOf(false) }
Expand Down Expand Up @@ -184,16 +178,6 @@ internal fun PostDetailScreen(
setIsDialogShow(true)
}
}
Row(
modifier = modifier.weight(0.45f)
) {
BitgoeulButton(
modifier = modifier.fillMaxWidth(),
text = "수정하기"
) {
// onEditClicked()
}
}
}
}
NegativeActionDialog(
Expand Down Expand Up @@ -224,7 +208,6 @@ fun PostDetailScreenPre() {
),
role = Authority.ROLE_ADMIN,
onDeleteClicked = {},
// onEditClicked = {},
id = UUID.randomUUID()
) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,11 @@ fun NavController.navigateToPostDetailPage(navOptions: NavOptions? = null) {
}

fun NavGraphBuilder.postDetailScreen(
// onEditClicked: () -> Unit,
onDeleteClicked: () -> Unit,
onBackClicked: () -> Unit
) {
composable(route = postDetailRoute) {
PostDetailScreenRoute(
// onEditClicked = onEditClicked,
onDeleteClicked = onDeleteClicked,
onBackClicked = onBackClicked
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.msg.post.viewmodel

import androidx.compose.runtime.mutableStateListOf
import androidx.compose.runtime.mutableStateOf
import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.msg.common.errorhandling.errorHandling
Expand All @@ -24,21 +23,16 @@ import javax.inject.Inject
@HiltViewModel
class PostViewModel @Inject constructor(
private val deletePostUseCase: DeletePostUseCase,
// private val editPostUseCase: EditPostUseCase,
private val getDetailPostUseCase: GetDetailPostUseCase,
private val getPostListUseCase: GetPostListUseCase,
private val getAuthorityUseCase: GetAuthorityUseCase,
private val savedStateHandle: SavedStateHandle
) : ViewModel() {

val role = getRole().toString()

private val _deletePostResponse = MutableStateFlow<Event<Unit>>(Event.Loading)
val deletePostResponse = _deletePostResponse.asStateFlow()

private val _editPostResponse = MutableStateFlow<Event<Unit>>(Event.Loading)
val editPostResponse = _editPostResponse.asStateFlow()

private val _getDetailPostResponse = MutableStateFlow<Event<GetDetailPostEntity>>(Event.Loading)
val getDetailPostResponse = _getDetailPostResponse.asStateFlow()

Expand Down Expand Up @@ -74,6 +68,7 @@ class PostViewModel @Inject constructor(
var isEditPage = mutableStateOf(false)
private set

// 아래의 삭제 함수를 저번 PR에서 실수로 삭제 못함 바로 삭제해야함
internal fun deletePost(
id: UUID
) = viewModelScope.launch {
Expand All @@ -88,31 +83,6 @@ class PostViewModel @Inject constructor(
}
}

// internal fun editPost(
// id: UUID,
// title: String,
// content: String,
// feedType: FeedType
// ) = viewModelScope.launch {
// editPostUseCase(
// id = id,
// body = WritePostParam(
// title = title,
// content = content,
// links = links,
// feedType = feedType
// )
// ).onSuccess {
// it.catch { remoteError ->
// _editPostResponse.value = remoteError.errorHandling()
// }.collect {
// _editPostResponse.value = Event.Success()
// }
// }.onFailure { error ->
// _editPostResponse.value = error.errorHandling()
// }
// }

internal fun getPostList(
type: FeedType
) = viewModelScope.launch {
Expand Down Expand Up @@ -147,13 +117,6 @@ class PostViewModel @Inject constructor(
}
}

internal fun getFilledEditPage() {
// onTitleChange(detailPost.value.title)
// onContentChange(detailPost.value.content)
links.addAll(detailPost.value.links)
isEditPage.value = true
}

private fun getRole() = viewModelScope.launch {
getAuthorityUseCase()
}
Expand Down

0 comments on commit 51d8dcd

Please sign in to comment.