Skip to content

Commit acdeabd

Browse files
committed
chore: cleanup IsOnlineTracker
1 parent bbd2720 commit acdeabd

File tree

2 files changed

+12
-27
lines changed

2 files changed

+12
-27
lines changed

app/src/main/java/to/bitkit/ui/MainActivity.kt

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -95,19 +95,18 @@ class MainActivity : FragmentActivity() {
9595
} else {
9696
val isAuthenticated by appViewModel.isAuthenticated.collectAsStateWithLifecycle()
9797

98-
IsOnlineTracker(appViewModel) {
99-
InactivityTracker(appViewModel, settingsViewModel) {
100-
ContentView(
101-
appViewModel = appViewModel,
102-
walletViewModel = walletViewModel,
103-
blocktankViewModel = blocktankViewModel,
104-
currencyViewModel = currencyViewModel,
105-
activityListViewModel = activityListViewModel,
106-
transferViewModel = transferViewModel,
107-
settingsViewModel = settingsViewModel,
108-
backupsViewModel = backupsViewModel,
109-
)
110-
}
98+
IsOnlineTracker(appViewModel)
99+
InactivityTracker(appViewModel, settingsViewModel) {
100+
ContentView(
101+
appViewModel = appViewModel,
102+
walletViewModel = walletViewModel,
103+
blocktankViewModel = blocktankViewModel,
104+
currencyViewModel = currencyViewModel,
105+
activityListViewModel = activityListViewModel,
106+
transferViewModel = transferViewModel,
107+
settingsViewModel = settingsViewModel,
108+
backupsViewModel = backupsViewModel,
109+
)
111110
}
112111

113112
AnimatedVisibility(

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

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ 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
8-
import androidx.compose.runtime.setValue
96
import androidx.compose.ui.platform.LocalContext
107
import androidx.lifecycle.compose.collectAsStateWithLifecycle
118
import to.bitkit.R
@@ -16,20 +13,11 @@ import to.bitkit.viewmodels.AppViewModel
1613
@Composable
1714
fun IsOnlineTracker(
1815
app: AppViewModel,
19-
content: @Composable () -> Unit,
2016
) {
2117
val context = LocalContext.current
2218
val connectivityState by app.isOnline.collectAsStateWithLifecycle(initialValue = ConnectivityState.CONNECTED)
2319

24-
var isInitialized by remember { mutableStateOf(false) }
25-
2620
LaunchedEffect(connectivityState) {
27-
// Skip the first emission to prevent toast on startup
28-
if (!isInitialized) {
29-
isInitialized = true
30-
return@LaunchedEffect
31-
}
32-
3321
when (connectivityState) {
3422
ConnectivityState.CONNECTED -> {
3523
app.toast(
@@ -50,6 +38,4 @@ fun IsOnlineTracker(
5038
else -> Unit
5139
}
5240
}
53-
54-
content()
5541
}

0 commit comments

Comments
 (0)