diff --git a/core/datastore/src/main/java/com/goalpanzi/mission_mate/core/datastore/datasource/DefaultDataSource.kt b/core/datastore/src/main/java/com/goalpanzi/mission_mate/core/datastore/datasource/DefaultDataSource.kt index e18f3cce..2178a358 100644 --- a/core/datastore/src/main/java/com/goalpanzi/mission_mate/core/datastore/datasource/DefaultDataSource.kt +++ b/core/datastore/src/main/java/com/goalpanzi/mission_mate/core/datastore/datasource/DefaultDataSource.kt @@ -7,4 +7,6 @@ interface DefaultDataSource { fun clearUserData() : Flow fun setUserProfile(data: UserProfile) : Flow fun getUserProfile() : Flow + fun setMemberId(data: Long) : Flow + fun getMemberId() : Flow } \ No newline at end of file diff --git a/core/datastore/src/main/java/com/goalpanzi/mission_mate/core/datastore/datasource/DefaultDataSourceImpl.kt b/core/datastore/src/main/java/com/goalpanzi/mission_mate/core/datastore/datasource/DefaultDataSourceImpl.kt index fe8ce237..0157e4d6 100644 --- a/core/datastore/src/main/java/com/goalpanzi/mission_mate/core/datastore/datasource/DefaultDataSourceImpl.kt +++ b/core/datastore/src/main/java/com/goalpanzi/mission_mate/core/datastore/datasource/DefaultDataSourceImpl.kt @@ -18,6 +18,7 @@ class DefaultDataSourceImpl @Inject constructor( object PreferencesKey { val USER_NICKNAME = stringPreferencesKey("USER_NICKNAME") val USER_CHARACTER = stringPreferencesKey("USER_CHARACTER") + val MEMBER_ID = stringPreferencesKey("MEMBER_ID") } override fun clearUserData(): Flow = flow { @@ -44,4 +45,15 @@ class DefaultDataSourceImpl @Inject constructor( null } } + + override fun setMemberId(data: Long): Flow = flow { + dataStore.edit { preferences -> + preferences[PreferencesKey.MEMBER_ID] = data.toString() + } + emit(Unit) + } + + override fun getMemberId(): Flow = dataStore.data.map { preferences -> + preferences[PreferencesKey.MEMBER_ID]?.toLong() + } } \ No newline at end of file diff --git a/core/domain/src/main/java/com/goalpanzi/mission_mate/core/domain/usecase/LoginUseCase.kt b/core/domain/src/main/java/com/goalpanzi/mission_mate/core/domain/usecase/LoginUseCase.kt index c1e39216..f4705352 100644 --- a/core/domain/src/main/java/com/goalpanzi/mission_mate/core/domain/usecase/LoginUseCase.kt +++ b/core/domain/src/main/java/com/goalpanzi/mission_mate/core/domain/usecase/LoginUseCase.kt @@ -22,6 +22,7 @@ class LoginUseCase @Inject constructor( response.data.also { authDataSource.setAccessToken(it.accessToken).first() authDataSource.setRefreshToken(it.refreshToken).first() + defaultDataSource.setMemberId(it.memberId).first() (it.nickname to it.characterType).let { (nickname, character) -> if (nickname != null && character != null) { defaultDataSource.setUserProfile( diff --git a/core/model/src/main/java/com/luckyoct/core/model/response/GoogleLogin.kt b/core/model/src/main/java/com/luckyoct/core/model/response/GoogleLogin.kt index a84d6628..a8ceb6de 100644 --- a/core/model/src/main/java/com/luckyoct/core/model/response/GoogleLogin.kt +++ b/core/model/src/main/java/com/luckyoct/core/model/response/GoogleLogin.kt @@ -9,5 +9,6 @@ data class GoogleLogin( val refreshToken: String, val nickname: String?, val characterType: CharacterType?, - val isProfileSet: Boolean + val isProfileSet: Boolean, + val memberId: Long ) diff --git a/feature/profile/src/main/java/com/luckyoct/feature/profile/ProfileViewModel.kt b/feature/profile/src/main/java/com/luckyoct/feature/profile/ProfileViewModel.kt index 5298d4c1..08776766 100644 --- a/feature/profile/src/main/java/com/luckyoct/feature/profile/ProfileViewModel.kt +++ b/feature/profile/src/main/java/com/luckyoct/feature/profile/ProfileViewModel.kt @@ -110,7 +110,6 @@ class ProfileViewModel @AssistedInject constructor( when(val response = profileUseCase.saveProfile(nickname, selectedItem.type)) { is NetworkResult.Success -> { - profileUseCase.saveProfile(nickname, selectedItem.type) _isSaveSuccess.emit(true) } is NetworkResult.Exception -> {}