Skip to content

Commit

Permalink
feat: added ability update the primary course on the learn tab (opene…
Browse files Browse the repository at this point in the history
  • Loading branch information
dixidroid authored Oct 29, 2024
1 parent 0de8db1 commit 44f106d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import androidx.compose.material.pullrefresh.pullRefresh
import androidx.compose.material.pullrefresh.rememberPullRefreshState
import androidx.compose.material.rememberScaffoldState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
Expand All @@ -53,6 +54,7 @@ import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.graphics.vector.rememberVectorPainter
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.pluralStringResource
Expand All @@ -63,6 +65,7 @@ import androidx.compose.ui.tooling.preview.Devices
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.fragment.app.FragmentManager
import androidx.lifecycle.Lifecycle
import coil.compose.AsyncImage
import coil.request.ImageRequest
import org.koin.androidx.compose.koinViewModel
Expand Down Expand Up @@ -108,6 +111,13 @@ fun DashboardGalleryView(
val uiMessage by viewModel.uiMessage.collectAsState(null)
val uiState by viewModel.uiState.collectAsState(DashboardGalleryUIState.Loading)

val lifecycleState by LocalLifecycleOwner.current.lifecycle.currentStateFlow.collectAsState()
LaunchedEffect(lifecycleState) {
if (lifecycleState == Lifecycle.State.RESUMED) {
viewModel.updateCourses(isUpdating = false)
}
}

DashboardGalleryView(
uiMessage = uiMessage,
uiState = uiState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ class DashboardGalleryViewModel(
}
}

fun updateCourses() {
fun updateCourses(isUpdating: Boolean = true) {
if (isLoading) {
return
}
_updating.value = true
_updating.value = isUpdating
getCourses()
}

Expand Down

0 comments on commit 44f106d

Please sign in to comment.