Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move unExpandedComments and commentsWithToggledActionBar from PostActivity to PostViewModel #1068

Merged
merged 7 commits into from
Jul 21, 2023
4 changes: 4 additions & 0 deletions app/src/main/java/com/jerboa/model/PostViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.jerboa.model

import android.content.Context
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateListOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.lifecycle.ViewModel
Expand Down Expand Up @@ -68,6 +69,9 @@ class PostViewModel : ViewModel(), Initializable {
private var blockCommunityRes: ApiState<BlockCommunityResponse> by mutableStateOf(ApiState.Empty)
private var blockPersonRes: ApiState<BlockPersonResponse> by mutableStateOf(ApiState.Empty)

val unExpandedComments = mutableStateListOf<Int>()
val commentsWithToggledActionBar = mutableStateListOf<Int>()

fun initialize(
id: Either<PostId, CommentId>,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import androidx.compose.material3.rememberTopAppBarState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateListOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
Expand Down Expand Up @@ -178,8 +177,8 @@ fun PostActivity(
val selectedSortType = postViewModel.sortType

// Holds expanded comment ids
val unExpandedComments = remember { mutableStateListOf<Int>() }
val commentsWithToggledActionBar = remember { mutableStateListOf<Int>() }
val unExpandedComments = postViewModel.unExpandedComments
val commentsWithToggledActionBar = postViewModel.commentsWithToggledActionBar
var showSortOptions by remember { mutableStateOf(false) }
val focusRequester = remember { FocusRequester() }

Expand Down