Skip to content
This repository has been archived by the owner on Apr 27, 2023. It is now read-only.

Commit

Permalink
feat: userId, profilemessage setting
Browse files Browse the repository at this point in the history
  • Loading branch information
sery270 committed Jan 26, 2023
1 parent 0f50aa9 commit ae0eb67
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
8 changes: 5 additions & 3 deletions app/src/main/java/org/sopt/stamp/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ import org.sopt.stamp.data.local.SoptampDataStoreModule
class App : Application() {

private lateinit var dataStore: SoptampDataStoreModule
fun getDataStore(): SoptampDataStoreModule = dataStore
override fun onCreate() {
super.onCreate()
soptampApplication = this
dataStore = SoptampDataStoreModule(this)
initFlipper()
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
dataStore = SoptampDataStoreModule(this)
}

private fun initFlipper() {
Expand All @@ -32,9 +34,9 @@ class App : Application() {
}
}

fun getDataStore(): SoptampDataStoreModule = dataStore

companion object {
val networkFlipperPlugin = NetworkFlipperPlugin()
private lateinit var soptampApplication: App
fun getInstance(): App = soptampApplication
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ data class UserResponse(
val statusCode: Int? = -1,
val profileMessage: String? = ""
) {
fun toUser() = User(userId, message, statusCode)
fun toUser() = User(userId, message, statusCode, profileMessage)
}
3 changes: 2 additions & 1 deletion app/src/main/java/org/sopt/stamp/domain/model/User.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ package org.sopt.stamp.domain.model
data class User(
val userId: Int?,
val message: String?,
val statusCode: Int?
val statusCode: Int?,
val profileMessage: String?
)
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.receiveAsFlow
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
import org.sopt.stamp.App
import org.sopt.stamp.data.repository.RemoteUserRepository
import javax.inject.Inject

Expand Down Expand Up @@ -42,6 +43,8 @@ class SoptampLoginViewModel @Inject constructor(
}
if (res.statusCode == 200) {
_singleEvent.trySend(SingleEvent.LoginSuccess)
res.userId?.let { App.getInstance().getDataStore().setUserId(it) }
res.profileMessage?.let { App.getInstance().getDataStore().setProfileMessage(it) }
}
}
}
Expand Down

0 comments on commit ae0eb67

Please sign in to comment.