Skip to content

Commit

Permalink
[refactor]#201: 데이터 로직 삭제
Browse files Browse the repository at this point in the history
  • Loading branch information
flash159483 committed Nov 25, 2024
1 parent e4b357d commit aa98e9d
Show file tree
Hide file tree
Showing 11 changed files with 5 additions and 264 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.bff.wespot.data.remote.source

import com.bff.wespot.data.remote.model.common.BackgroundColorListDto
import com.bff.wespot.data.remote.model.common.CharacterListDto
import com.bff.wespot.data.remote.model.common.EditProfileDto
import com.bff.wespot.data.remote.model.common.ImageUrlDto
import com.bff.wespot.data.remote.model.common.KakaoContentDto
Expand All @@ -12,9 +10,7 @@ import com.bff.wespot.data.remote.model.common.RestrictionDto
interface CommonDataSource {
suspend fun checkProfanity(content: ProfanityDto): Result<Unit>
suspend fun sendReport(report: ReportDto): Result<Unit>
suspend fun getCharacters(): Result<CharacterListDto>
suspend fun getBackgroundColors(): Result<BackgroundColorListDto>
suspend fun EditProfile(
suspend fun editProfile(
profile: EditProfileDto
): Result<Unit>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.bff.wespot.data.remote.source

import com.bff.wespot.data.remote.model.common.BackgroundColorListDto
import com.bff.wespot.data.remote.model.common.CharacterListDto
import com.bff.wespot.data.remote.model.common.EditProfileDto
import com.bff.wespot.data.remote.model.common.ImageUrlDto
import com.bff.wespot.data.remote.model.common.KakaoContentDto
Expand Down Expand Up @@ -40,23 +38,7 @@ class CommonDataSourceImpl @Inject constructor(
}
}

override suspend fun getCharacters(): Result<CharacterListDto> =
httpClient.safeRequest {
url {
method = HttpMethod.Get
path("api/v1/users/characters")
}
}

override suspend fun getBackgroundColors(): Result<BackgroundColorListDto> =
httpClient.safeRequest {
url {
method = HttpMethod.Get
path("api/v1/users/backgrounds")
}
}

override suspend fun EditProfile(profile: EditProfileDto): Result<Unit> =
override suspend fun editProfile(profile: EditProfileDto): Result<Unit> =
httpClient.safeRequest {
url {
method = HttpMethod.Put
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import com.bff.wespot.data.remote.model.common.UpdateProfileDto
import com.bff.wespot.data.remote.source.CommonDataSource
import com.bff.wespot.data.remote.source.ImageDecoderDataSource
import com.bff.wespot.domain.repository.CommonRepository
import com.bff.wespot.model.common.BackgroundColor
import com.bff.wespot.model.common.Character
import com.bff.wespot.model.common.KakaoContent
import com.bff.wespot.model.common.ReportType
import com.bff.wespot.model.common.Restriction
Expand All @@ -28,20 +26,12 @@ class CommonRepositoryImpl @Inject constructor(
content: String?,
): Result<Unit> = commonDataSource.sendReport(ReportDto(targetId, report, content))

override suspend fun getCharacters(): Result<List<Character>> =
commonDataSource.getCharacters()
.mapCatching { it.toCharacterList().characters }

override suspend fun getBackgroundColors(): Result<List<BackgroundColor>> =
commonDataSource.getBackgroundColors()
.mapCatching { it.toBackgroundColorList().backgrounds }

override suspend fun EditProfile(
override suspend fun editProfile(
introduction: String,
backgroundColor: String,
iconUrl: String
): Result<Unit> =
commonDataSource.EditProfile(
commonDataSource.editProfile(
EditProfileDto(
introduction,
UpdateProfileDto(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
package com.bff.wespot.domain.repository

import com.bff.wespot.model.common.BackgroundColor
import com.bff.wespot.model.common.Character
import com.bff.wespot.model.common.KakaoContent
import com.bff.wespot.model.common.ReportType
import com.bff.wespot.model.common.Restriction

interface CommonRepository {
suspend fun checkProfanity(content: String): Result<Unit>
suspend fun sendReport(report: ReportType, targetId: Int, content: String? = null): Result<Unit>
suspend fun getCharacters(): Result<List<Character>>
suspend fun getBackgroundColors(): Result<List<BackgroundColor>>
suspend fun EditProfile(
suspend fun editProfile(
introduction: String,
backgroundColor: String,
iconUrl: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.bff.wespot.entire.state.edit

sealed class EntireEditAction {
data object OnCharacterEditScreenEntered : EntireEditAction()
data object OnProfileEditDoneButtonClicked : EntireEditAction()
data class OnProfileEditScreenEntered(val isCompleteEdit: Boolean) : EntireEditAction()
data class OnProfileEditTextFieldFocused(val focused: Boolean) : EntireEditAction()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ class EntireEditViewModel @Inject constructor(

fun onAction(action: EntireEditAction) = intent {
when (action) {
EntireEditAction.OnCharacterEditScreenEntered -> {
handleCharacterEditScreenEntered()
observeProfileFlow()
}

EntireEditAction.OnProfileEditDoneButtonClicked -> {
updateIntroduction()
uploadProfileImage()
Expand Down Expand Up @@ -85,30 +80,6 @@ class EntireEditViewModel @Inject constructor(
}
}

private fun handleCharacterEditScreenEntered() = intent {
viewModelScope.launch {
launch {
commonRepository.getBackgroundColors()
.onSuccess { backgroundColorList ->
reduce { state.copy(backgroundColorList = backgroundColorList) }
}
.onNetworkFailure {
postSideEffect(it.toSideEffect())
}
}

launch {
commonRepository.getCharacters()
.onSuccess { characterList ->
reduce { state.copy(characterList = characterList) }
}
.onNetworkFailure {
postSideEffect(it.toSideEffect())
}
}
}
}

private fun handleProfileEditScreenEntered() {
viewModelScope.launch {
runCatching {
Expand All @@ -127,7 +98,6 @@ class EntireEditViewModel @Inject constructor(
Timber.e(exception)
}
.collect {
Timber.d("Profile change: $it")
reduce { state.copy(profile = it, profilePath = it.profileCharacter.iconUrl) }
}
}
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit aa98e9d

Please sign in to comment.