Skip to content

Commit

Permalink
#219 앱 프로세스를 다시 시작하였을 떄 세션정보를 다시 로드하는 로직을 구현할 loadSession()을 AccountS…
Browse files Browse the repository at this point in the history
…essionRepository에 추가
  • Loading branch information
pknujsp committed Mar 11, 2024
1 parent 52e07cb commit 1bca783
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.android.mediproject.core.data

import com.amazonaws.mobileconnectors.cognitoidentityprovider.CognitoUserPool
import com.android.mediproject.core.common.network.Dispatcher
import com.android.mediproject.core.common.network.MediDispatchers
import com.android.mediproject.core.data.adminaction.AdminActionRepository
Expand Down Expand Up @@ -138,7 +139,8 @@ object RepositoryModule {
@Singleton
fun providesAccountSessionRepository(
appDataStore: AppDataStore,
): AccountSessionRepository = AccountSessionRepositoryImpl(appDataStore)
cognitoUserPool: CognitoUserPool,
): AccountSessionRepository = AccountSessionRepositoryImpl(appDataStore, cognitoUserPool)


@Provides
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ interface AccountSessionRepository {
val signedIn: Boolean
suspend fun updateSession(session: CognitoUserSession?)
suspend fun updateAccount(email: String, nickName: String = "")

suspend fun loadSession()
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.android.mediproject.core.data.session

import com.amazonaws.mobileconnectors.cognitoidentityprovider.CognitoUserPool
import com.amazonaws.mobileconnectors.cognitoidentityprovider.CognitoUserSession
import com.android.mediproject.core.datastore.AppDataStore
import com.android.mediproject.core.model.user.UserEntity
Expand All @@ -9,6 +10,7 @@ import kotlinx.coroutines.flow.distinctUntilChanged

class AccountSessionRepositoryImpl(
private val appDataStore: AppDataStore,
private val userPool: CognitoUserPool,
) : AccountSessionRepository {
override val lastSavedEmail = appDataStore.userEmail.distinctUntilChanged()

Expand All @@ -25,6 +27,7 @@ class AccountSessionRepositoryImpl(
mutableSession.value = session

if (session == null) {
mutableUserOnCurrentSession.value = null
appDataStore.clearMyAccountInfo()
}
}
Expand All @@ -33,4 +36,9 @@ class AccountSessionRepositoryImpl(
mutableUserOnCurrentSession.value = UserEntity(email, nickName)
appDataStore.saveMyAccountInfo(email, nickName)
}

override suspend fun loadSession() {

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ class MyPageViewModel @Inject constructor(
private val signRepository: SignRepository,
@Dispatcher(MediDispatchers.IO) private val ioDispatcher: CoroutineDispatcher,
) : BaseViewModel() {


val currentUser = accountSessionRepository.userOnCurrentSession

private val _eventFlow = MutableEventFlow<MyPageEvent>()
val eventFlow = _eventFlow.asEventFlow()

Expand Down

0 comments on commit 1bca783

Please sign in to comment.