Skip to content

Does not give Status update when app is started without internet #18

Closed
@Vaibhav2002

Description

@Vaibhav2002

If I start app without Internet, I dont get the status update that there is no update, but if I connect to internet and then disable again, it gives the update

Code

Composable

val isConnected by component.isConnected.collectAsState()

LaunchedEffect(isConnected) {
    if (isConnected) {
        snackBarHostState.currentSnackbarData?.dismiss()
        return@LaunchedEffect
    }
    MedialSnackBarVisuals(
        message = "No Internet Connection",
        snackBarType = SnackBarType.Default,
        duration = SnackbarDuration.Indefinite
    ).also { snackBarHostState.showSnackbar(it) }
}

Component

val isConnected = connectivity.statusUpdates
    .mapLatest { it.isConnected }
    .toStateFlow(componentScope, true)

init {
    doOnResume { networkHelper.startUpdates() }
    doOnPause { networkHelper.stopUpdates() }
}

I have also tried using the compose-device dependency, but that too does not work
The connectivity status has value null

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions