-
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.
- Loading branch information
Showing
13 changed files
with
318 additions
and
165 deletions.
There are no files selected for viewing
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
3 changes: 2 additions & 1 deletion
3
...main/src/main/java/com/goalpanzi/mission_mate/core/domain/repository/ProfileRepository.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,8 +1,9 @@ | ||
package com.goalpanzi.mission_mate.core.domain.repository | ||
|
||
import com.goalpanzi.mission_mate.core.network.ResultHandler | ||
import com.luckyoct.core.model.CharacterType | ||
import com.luckyoct.core.model.base.NetworkResult | ||
|
||
interface ProfileRepository: ResultHandler { | ||
suspend fun saveProfile(nickname: String, index: Int): NetworkResult<Unit> | ||
suspend fun saveProfile(nickname: String, type: CharacterType): NetworkResult<Unit> | ||
} |
15 changes: 13 additions & 2 deletions
15
core/domain/src/main/java/com/goalpanzi/mission_mate/core/domain/usecase/ProfileUseCase.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,10 +1,21 @@ | ||
package com.goalpanzi.mission_mate.core.domain.usecase | ||
|
||
import com.goalpanzi.mission_mate.core.datastore.datasource.DefaultDataSource | ||
import com.goalpanzi.mission_mate.core.domain.repository.ProfileRepository | ||
import com.luckyoct.core.model.CharacterType | ||
import com.luckyoct.core.model.UserProfile | ||
import com.luckyoct.core.model.base.NetworkResult | ||
import kotlinx.coroutines.flow.first | ||
import javax.inject.Inject | ||
|
||
class ProfileUseCase @Inject constructor( | ||
private val profileRepository: ProfileRepository | ||
private val profileRepository: ProfileRepository, | ||
private val defaultDataSource: DefaultDataSource | ||
) { | ||
suspend fun saveProfile(nickname: String, index: Int) = profileRepository.saveProfile(nickname, index) | ||
suspend fun saveProfile(nickname: String, type: CharacterType) = profileRepository.saveProfile(nickname, type).also { | ||
if (it is NetworkResult.Success) { | ||
defaultDataSource.setUserProfile(UserProfile(nickname, type)).first() | ||
} | ||
} | ||
suspend fun getProfile(): UserProfile? = defaultDataSource.getUserProfile().first() | ||
} |
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
2 changes: 1 addition & 1 deletion
2
core/model/src/main/java/com/luckyoct/core/model/response/MissionBoardMembersResponse.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
2 changes: 1 addition & 1 deletion
2
core/model/src/main/java/com/luckyoct/core/model/response/MissionVerificationResponse.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
2 changes: 1 addition & 1 deletion
2
feature/board/src/main/java/com/goalpanzi/mission_mate/feature/board/model/Character.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
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
Oops, something went wrong.