Курсовая: Готова и сдана
This commit is contained in:
parent
40ca46846e
commit
cf8e779058
@ -112,7 +112,7 @@ interface ServerService {
|
||||
): User
|
||||
|
||||
companion object {
|
||||
private const val BASE_URL = "http://192.168.0.103:8000/"
|
||||
private const val BASE_URL = "http://192.168.43.115:8000/"
|
||||
|
||||
private var _token: String = ""
|
||||
|
||||
|
@ -161,8 +161,7 @@ private fun Post(viewModel: PostsViewModel, navController: NavHostController, po
|
||||
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxHeight(0.3f)
|
||||
.heightIn(max = 250.dp)
|
||||
.heightIn(min=250.dp, max = 300.dp)
|
||||
.fillMaxWidth()
|
||||
.background(Color.White)
|
||||
.clickable {
|
||||
|
@ -203,6 +203,12 @@ fun Post(viewModel: TopPostsViewModel, navController: NavHostController, post: P
|
||||
val likes = remember { mutableIntStateOf(post.likes) }
|
||||
val isLiked = remember { mutableStateOf(false) }
|
||||
|
||||
LaunchedEffect(Unit) {
|
||||
viewModel.getLikes(post.id!!).collect {
|
||||
likes.intValue = it
|
||||
}
|
||||
}
|
||||
|
||||
LaunchedEffect(Unit) {
|
||||
viewModel.isLiked(sharedPref, post.id!!).collect {
|
||||
isLiked.value = it
|
||||
|
@ -35,6 +35,8 @@ class TopPostsViewModel @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
fun getLikes(postId: Int) = likeRepository.countByPost(postId)
|
||||
|
||||
fun likePost(sharedPref: PreferencesManager, postId: Int) {
|
||||
val userId = sharedPref.getData("userId", "-1").toInt()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user