Skip to content

Commit 673df9f

Browse files
committed
fix: restore IsOnlineTracker startup toast prevention
1 parent 01ee37c commit 673df9f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

app/src/main/java/to/bitkit/ui/components/IsOnlineTracker.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package to.bitkit.ui.components
33
import androidx.compose.runtime.Composable
44
import androidx.compose.runtime.LaunchedEffect
55
import androidx.compose.runtime.getValue
6+
import androidx.compose.runtime.mutableStateOf
7+
import androidx.compose.runtime.remember
68
import androidx.compose.ui.platform.LocalContext
79
import androidx.lifecycle.compose.collectAsStateWithLifecycle
810
import to.bitkit.R
@@ -17,7 +19,15 @@ fun IsOnlineTracker(
1719
val context = LocalContext.current
1820
val connectivityState by app.isOnline.collectAsStateWithLifecycle(initialValue = ConnectivityState.CONNECTED)
1921

22+
val (isFirstEmission, setIsFirstEmission) = remember { mutableStateOf(true) }
23+
2024
LaunchedEffect(connectivityState) {
25+
// Skip the first emission to prevent toast on startup
26+
if (isFirstEmission) {
27+
setIsFirstEmission(true)
28+
return@LaunchedEffect
29+
}
30+
2131
when (connectivityState) {
2232
ConnectivityState.CONNECTED -> {
2333
app.toast(

0 commit comments

Comments
 (0)