Skip to content

Commit

Permalink
#219 AppDataStore내 계정ID 관련 필드 삭제 ServerNetwork 모듈 내 쓰이지 않는 인스턴스 제공자 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
pknujsp committed Mar 11, 2024
1 parent c8c8c93 commit e5146c2
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ interface AppDataStore {
val userEmail: Flow<String>
val nickName: Flow<String>
val skipIntro: Flow<Boolean>
val myAccountId: Flow<Long>
suspend fun saveMyAccountInfo(email: String, nickName: String)
suspend fun saveNickName(nickName: String)
suspend fun saveSkipIntro(skipIntro: Boolean)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,21 @@ package com.android.mediproject.core.datastore
import android.content.Context
import androidx.datastore.preferences.core.booleanPreferencesKey
import androidx.datastore.preferences.core.edit
import androidx.datastore.preferences.core.longPreferencesKey
import androidx.datastore.preferences.core.stringPreferencesKey
import androidx.datastore.preferences.preferencesDataStore
import dagger.hilt.android.qualifiers.ApplicationContext
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map
import javax.inject.Inject


class AppDataStoreImpl @Inject constructor(
class AppDataStoreImpl(
@ApplicationContext private val context: Context,
) : AppDataStore {
private val Context.dataStore by preferencesDataStore("user_preferences")

private val KEY_USER_EMAIL = stringPreferencesKey("user_email")
private val KEY_NICK_NAME = stringPreferencesKey("nick_name")
private val KEY_SKIP_INTRO = booleanPreferencesKey("skip_intro")
private val KEY_MY_ACCOUNT_ID = longPreferencesKey("my_account_id")


override val userEmail: Flow<String> = context.dataStore.data.map { it[KEY_USER_EMAIL] ?: "" }

Expand All @@ -31,16 +27,10 @@ class AppDataStoreImpl @Inject constructor(
it[KEY_SKIP_INTRO] ?: false
}

override val myAccountId: Flow<Long> = context.dataStore.data.map {
it[KEY_MY_ACCOUNT_ID] ?: 0L
}


override suspend fun saveMyAccountInfo(email: String, nickName: String) {
context.dataStore.edit {
it[KEY_USER_EMAIL] = email
it[KEY_NICK_NAME] = nickName
it[KEY_MY_ACCOUNT_ID] = myAccountId
}
}

Expand All @@ -56,7 +46,6 @@ class AppDataStoreImpl @Inject constructor(
context.dataStore.edit {
it[KEY_USER_EMAIL] = ""
it[KEY_NICK_NAME] = ""
it[KEY_MY_ACCOUNT_ID] = 0
it[KEY_SKIP_INTRO] = false
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import javax.inject.Singleton
@InstallIn(SingletonComponent::class)
object DataStoreModule {


@Provides
@Singleton
fun providesAppDataStore(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import com.android.mediproject.core.model.requestparameters.GetMedicineIdParamet
import com.android.mediproject.core.model.requestparameters.NewCommentParameter
import com.android.mediproject.core.model.user.remote.ChangeNicknameResponse
import com.android.mediproject.core.model.user.remote.ChangePasswordResponse
import com.android.mediproject.core.model.user.remote.UserResponse
import com.android.mediproject.core.model.user.remote.WithdrawalResponse
import com.android.mediproject.core.network.datasource.comments.CommentsDataSource
import com.android.mediproject.core.network.datasource.comments.CommentsDataSourceImpl
Expand All @@ -35,6 +34,7 @@ import com.android.mediproject.core.network.datasource.sign.SignDataSource
import com.android.mediproject.core.network.datasource.sign.SignDataSourceImpl
import com.android.mediproject.core.network.datasource.sign.SignInOutAWSImpl
import com.android.mediproject.core.network.datasource.sign.SignUpAWSImpl
import com.android.mediproject.core.network.datasource.sign.VerifyEmailImpl
import com.android.mediproject.core.network.datasource.user.UserDataSource
import com.android.mediproject.core.network.datasource.user.UserDataSourceImpl
import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory
Expand Down Expand Up @@ -94,27 +94,17 @@ object ServerNetwork {
context, BuildConfig.AWS_USER_POOL, BuildConfig.AWS_USER_CLIENT_ID, BuildConfig.AWS_USER_CLIENT_SECRET,
Regions.US_EAST_2,
)
return SignDataSourceImpl(SignInOutAWSImpl(userPool), SignUpAWSImpl(userPool))
return SignDataSourceImpl(SignInOutAWSImpl(userPool), SignUpAWSImpl(userPool), VerifyEmailImpl(userPool))
}

@Provides
@Singleton
fun providesGetMedicineIdDataSource(awsNetworkApi: AwsNetworkApi): MedicineIdDataSource = MedicineIdDataSourceImpl(awsNetworkApi)

@Provides
@Singleton
fun providesUserInfosDataSource(awsNetworkApi: AwsNetworkApi): UserInfoDataSource = UserInfoDataSourceImpl(awsNetworkApi)

@Provides
@Singleton
fun providesUserDataSource(awsNetworkApi: AwsNetworkApi, aesCoder: AesCoder): UserDataSource = UserDataSourceImpl(awsNetworkApi, aesCoder)

/* @Provides
@Singleton
fun providesTokenDataSource(
awsNetworkApi: AwsNetworkApi,
tokenServer: TokenServer,
): TokenDataSource = TokenDataSourceImpl(awsNetworkApi, tokenServer)*/
}

interface AwsNetworkApi {
Expand Down Expand Up @@ -227,12 +217,6 @@ interface AwsNetworkApi {
@Body getMedicineIdParameter: GetMedicineIdParameter,
): Response<MedicineIdResponse>

/**
* 유저 정보 조회
*/
@GET(value = "user")
suspend fun getUserInfo(): Response<UserResponse>

/**
* 관심 약 조회
*/
Expand Down

0 comments on commit e5146c2

Please sign in to comment.