Fixes SelectedProfileState
This commit is contained in:
parent
204ca8f67e
commit
0bf15a1647
5 changed files with 18 additions and 22 deletions
|
@ -5,6 +5,7 @@ import be.ugent.sel.studeez.data.local.models.task.Subject
|
|||
import be.ugent.sel.studeez.data.local.models.task.Task
|
||||
import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalTimer
|
||||
import be.ugent.sel.studeez.data.local.models.timer_info.TimerInfo
|
||||
import be.ugent.sel.studeez.domain.UserDAO
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
|
@ -42,4 +43,11 @@ class SelectedSubject @Inject constructor() : SelectedState<Subject>() {
|
|||
@Singleton
|
||||
class SelectedTimerInfo @Inject constructor() : SelectedState<TimerInfo>() {
|
||||
override lateinit var value: TimerInfo
|
||||
}
|
||||
|
||||
@Singleton
|
||||
class SelectedUserId @Inject constructor(
|
||||
userDAO: UserDAO
|
||||
): SelectedState<String>() {
|
||||
override var value: String = userDAO.getCurrentUserId()
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package be.ugent.sel.studeez.screens.friends.friends_overview
|
||||
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import be.ugent.sel.studeez.data.SelectedUserId
|
||||
import be.ugent.sel.studeez.data.local.models.Friendship
|
||||
import be.ugent.sel.studeez.data.local.models.User
|
||||
import be.ugent.sel.studeez.domain.FriendshipDAO
|
||||
|
@ -8,7 +9,6 @@ import be.ugent.sel.studeez.domain.LogService
|
|||
import be.ugent.sel.studeez.domain.UserDAO
|
||||
import be.ugent.sel.studeez.navigation.StudeezDestinations
|
||||
import be.ugent.sel.studeez.screens.StudeezViewModel
|
||||
import be.ugent.sel.studeez.screens.profile.public_profile.SelectedProfileState
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.combine
|
||||
|
@ -19,12 +19,12 @@ import javax.inject.Inject
|
|||
class FriendsOverviewViewModel @Inject constructor(
|
||||
private val userDAO: UserDAO,
|
||||
private val friendshipDAO: FriendshipDAO,
|
||||
private val selectedProfileState: SelectedProfileState,
|
||||
private val selectedUserIdState: SelectedUserId,
|
||||
logService: LogService
|
||||
) : StudeezViewModel(logService) {
|
||||
|
||||
var uiState = mutableStateOf(FriendsOverviewUiState(
|
||||
userId = selectedProfileState.selectedUserId
|
||||
userId = selectedUserIdState.value
|
||||
))
|
||||
private set
|
||||
|
||||
|
@ -63,7 +63,7 @@ class FriendsOverviewViewModel @Inject constructor(
|
|||
userId: String,
|
||||
open: (String) -> Unit
|
||||
) {
|
||||
selectedProfileState.selectedUserId = userId
|
||||
selectedUserIdState.value = userId
|
||||
open(StudeezDestinations.PUBLIC_PROFILE_SCREEN)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package be.ugent.sel.studeez.screens.friends.friends_search
|
||||
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import be.ugent.sel.studeez.data.SelectedUserId
|
||||
import be.ugent.sel.studeez.data.local.models.User
|
||||
import be.ugent.sel.studeez.data.remote.FirebaseUser
|
||||
import be.ugent.sel.studeez.domain.LogService
|
||||
import be.ugent.sel.studeez.domain.UserDAO
|
||||
import be.ugent.sel.studeez.navigation.StudeezDestinations
|
||||
import be.ugent.sel.studeez.screens.StudeezViewModel
|
||||
import be.ugent.sel.studeez.screens.profile.public_profile.SelectedProfileState
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.filter
|
||||
|
@ -16,7 +16,7 @@ import javax.inject.Inject
|
|||
@HiltViewModel
|
||||
class SearchFriendsViewModel @Inject constructor(
|
||||
private val userDAO: UserDAO,
|
||||
private val selectedProfileState: SelectedProfileState,
|
||||
private val selectedProfileState: SelectedUserId,
|
||||
logService: LogService
|
||||
): StudeezViewModel(logService) {
|
||||
|
||||
|
@ -60,7 +60,7 @@ class SearchFriendsViewModel @Inject constructor(
|
|||
userId: String,
|
||||
open: (String) -> Unit
|
||||
) {
|
||||
selectedProfileState.selectedUserId = userId
|
||||
selectedProfileState.value = userId
|
||||
open(StudeezDestinations.PUBLIC_PROFILE_SCREEN)
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package be.ugent.sel.studeez.screens.profile.public_profile
|
||||
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import be.ugent.sel.studeez.data.SelectedUserId
|
||||
import be.ugent.sel.studeez.data.local.models.User
|
||||
import be.ugent.sel.studeez.domain.FriendshipDAO
|
||||
import be.ugent.sel.studeez.domain.LogService
|
||||
|
@ -9,20 +10,19 @@ import be.ugent.sel.studeez.navigation.StudeezDestinations
|
|||
import be.ugent.sel.studeez.screens.StudeezViewModel
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.selects.select
|
||||
import javax.inject.Inject
|
||||
|
||||
@HiltViewModel
|
||||
class PublicProfileViewModel @Inject constructor(
|
||||
private val userDAO: UserDAO,
|
||||
private val friendshipDAO: FriendshipDAO,
|
||||
selectedProfileState: SelectedProfileState,
|
||||
selectedUserIdState: SelectedUserId,
|
||||
logService: LogService
|
||||
): StudeezViewModel(logService) {
|
||||
|
||||
val uiState = mutableStateOf(
|
||||
PublicProfileUiState(
|
||||
userId = selectedProfileState.selectedUserId
|
||||
userId = selectedUserIdState.value
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
package be.ugent.sel.studeez.screens.profile.public_profile
|
||||
|
||||
import be.ugent.sel.studeez.domain.UserDAO
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Singleton
|
||||
class SelectedProfileState @Inject constructor(
|
||||
userDAO: UserDAO
|
||||
) {
|
||||
var selectedUserId: String = userDAO.getCurrentUserId()
|
||||
}
|
Reference in a new issue