-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feat] #43 Proto DataStore에 OnboardingInfo 정의
- Loading branch information
Showing
4 changed files
with
53 additions
and
20 deletions.
There are no files selected for viewing
58 changes: 39 additions & 19 deletions
58
app/src/main/java/org/android/bbangzip/data/repositoryImpl/UserRepositoryImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,53 @@ | ||
package org.android.bbangzip.data.repositoryImpl | ||
|
||
import kotlinx.coroutines.flow.Flow | ||
import org.android.bbangzip.OnboardingInfo | ||
import org.android.bbangzip.UserPreferences | ||
import org.android.bbangzip.data.datasource.local.UserLocalDataSource | ||
import org.android.bbangzip.domain.repository.local.UserRepository | ||
import javax.inject.Inject | ||
|
||
class UserRepositoryImpl | ||
@Inject | ||
constructor( | ||
private val userDataSource: UserLocalDataSource, | ||
) : UserRepository { | ||
override val userPreferenceFlow: Flow<UserPreferences> = userDataSource.userPreferencesFlow | ||
@Inject | ||
constructor( | ||
private val userDataSource: UserLocalDataSource, | ||
) : UserRepository { | ||
override val userPreferenceFlow: Flow<UserPreferences> = userDataSource.userPreferencesFlow | ||
|
||
override suspend fun setUserData(accessToken: String) { | ||
userDataSource.updateUserPreferences { userData -> | ||
userData | ||
.toBuilder() | ||
.setAccessToken(accessToken) | ||
.build() | ||
} | ||
override suspend fun setUserData(accessToken: String) { | ||
userDataSource.updateUserPreferences { userData -> | ||
userData | ||
.toBuilder() | ||
.setAccessToken(accessToken) | ||
.build() | ||
} | ||
} | ||
|
||
override suspend fun clearUserData() { | ||
userDataSource.updateUserPreferences { userData -> | ||
userData | ||
.toBuilder() | ||
.clearAccessToken() | ||
.clearOnboardingInfo() | ||
.build() | ||
} | ||
} | ||
|
||
override suspend fun setOnboardingInfo(onboardingInfo: OnboardingInfo) { | ||
userDataSource.updateUserPreferences { userData -> | ||
userData | ||
.toBuilder() | ||
.setOnboardingInfo(onboardingInfo) | ||
.build() | ||
} | ||
} | ||
|
||
override suspend fun clearUserData() { | ||
userDataSource.updateUserPreferences { userData -> | ||
userData | ||
.toBuilder() | ||
.clearAccessToken() | ||
.build() | ||
} | ||
override suspend fun clearOnboardingInfo() { | ||
userDataSource.updateUserPreferences { userData -> | ||
userData | ||
.toBuilder() | ||
.clearOnboardingInfo() | ||
.build() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters