Skip to content

Commit

Permalink
Move unExpandedComments and commentsWithToggledActionBar from PostAct…
Browse files Browse the repository at this point in the history
…ivity to PostViewModel (#1068)

* Move unExpandedComments and commentsWithToggledActionBar from PostActivity to PostViewModel

* Fix formatting

---------

Co-authored-by: Maarten Vercruysse <67873169+MV-GH@users.noreply.github.com>
  • Loading branch information
twizmwazin and MV-GH authored Jul 21, 2023
1 parent 3aa898f commit abec22b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
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

0 comments on commit abec22b

Please sign in to comment.