From e1afaa92c466d00c672548760602cf1e69cea707 Mon Sep 17 00:00:00 2001 From: kwakjoohyeong Date: Sun, 31 Mar 2024 15:35:57 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=EB=B6=84=EA=B8=B0=EA=B0=80=203?= =?UTF-8?q?=EA=B0=9C=EC=9D=B4=EC=83=81=EC=9D=BC=EC=8B=9C=EC=97=90=20if->?= =?UTF-8?q?=20when=EC=9D=84=20=EC=82=AC=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/data/mapper/ChangedProfileMapper.kt | 3 ++- .../domain/model/profile/ChangedProfile.kt | 4 ++-- .../model/profile/ProfileChangingStatus.kt | 18 +++++++++--------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/core/data/src/main/kotlin/com/withpeace/withpeace/core/data/mapper/ChangedProfileMapper.kt b/core/data/src/main/kotlin/com/withpeace/withpeace/core/data/mapper/ChangedProfileMapper.kt index 0c1b07d9..dcfc9090 100644 --- a/core/data/src/main/kotlin/com/withpeace/withpeace/core/data/mapper/ChangedProfileMapper.kt +++ b/core/data/src/main/kotlin/com/withpeace/withpeace/core/data/mapper/ChangedProfileMapper.kt @@ -1,11 +1,12 @@ package com.withpeace.withpeace.core.data.mapper import com.withpeace.withpeace.core.domain.model.profile.ChangedProfile +import com.withpeace.withpeace.core.domain.model.profile.Nickname import com.withpeace.withpeace.core.network.di.response.ChangedProfileResponse fun ChangedProfileResponse.toDomain(): ChangedProfile { return ChangedProfile( - nickname = this.nickname, + nickname = Nickname.create(this.nickname), profileImageUrl = profileImageUrl, ) } diff --git a/core/domain/src/main/java/com/withpeace/withpeace/core/domain/model/profile/ChangedProfile.kt b/core/domain/src/main/java/com/withpeace/withpeace/core/domain/model/profile/ChangedProfile.kt index 72ca746d..af2cdcf7 100644 --- a/core/domain/src/main/java/com/withpeace/withpeace/core/domain/model/profile/ChangedProfile.kt +++ b/core/domain/src/main/java/com/withpeace/withpeace/core/domain/model/profile/ChangedProfile.kt @@ -1,6 +1,6 @@ package com.withpeace.withpeace.core.domain.model.profile data class ChangedProfile( - val nickname: String, - val profileImageUrl: String, + val nickname: Nickname?, + val profileImageUrl: String?, ) diff --git a/core/domain/src/main/java/com/withpeace/withpeace/core/domain/model/profile/ProfileChangingStatus.kt b/core/domain/src/main/java/com/withpeace/withpeace/core/domain/model/profile/ProfileChangingStatus.kt index f48c3bfb..a229763c 100644 --- a/core/domain/src/main/java/com/withpeace/withpeace/core/domain/model/profile/ProfileChangingStatus.kt +++ b/core/domain/src/main/java/com/withpeace/withpeace/core/domain/model/profile/ProfileChangingStatus.kt @@ -10,15 +10,15 @@ sealed interface ProfileChangingStatus { beforeProfile: ChangingProfileInfo, afterProfile: ChangingProfileInfo, ): ProfileChangingStatus { - return if (beforeProfile.profileImage != afterProfile.profileImage - && afterProfile.nickname != beforeProfile.nickname && afterProfile.profileImage != null - ) { - AllChanging - } else if (afterProfile.profileImage != null && beforeProfile.profileImage != afterProfile.profileImage - ) { - OnlyImageChanging - } else { - OnlyNicknameChanging + return when { + beforeProfile.profileImage != afterProfile.profileImage && + afterProfile.nickname != beforeProfile.nickname && + afterProfile.profileImage != null -> AllChanging + + afterProfile.profileImage != null && + beforeProfile.profileImage != afterProfile.profileImage -> OnlyImageChanging + + else -> OnlyNicknameChanging } } }