Move some package on core + try some stuff around sync/roomlist
This commit is contained in:
parent
6cf010db44
commit
1ec8b3a994
18 changed files with 106 additions and 43 deletions
|
|
@ -11,12 +11,14 @@ import androidx.compose.material3.ExperimentalMaterial3Api
|
|||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import com.ramcosta.composedestinations.DestinationsNavHost
|
||||
import com.ramcosta.composedestinations.rememberNavHostEngine
|
||||
import io.element.android.x.core.compose.OnLifecycleEvent
|
||||
import io.element.android.x.designsystem.ElementXTheme
|
||||
import io.element.android.x.destinations.LoginScreenNavigationDestination
|
||||
import io.element.android.x.destinations.OnBoardingScreenNavigationDestination
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import timber.log.Timber
|
||||
|
||||
class MainActivity : ComponentActivity() {
|
||||
|
||||
|
|
@ -52,4 +54,8 @@ private fun MainScreen(viewModel: MainViewModel) {
|
|||
navGraph = NavGraphs.root,
|
||||
startRoute = startRoute
|
||||
)
|
||||
|
||||
OnLifecycleEvent { _, event ->
|
||||
Timber.v("OnLifecycleEvent: $event")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
package io.element.android.x
|
||||
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import io.element.android.x.matrix.MatrixInstance
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class MainViewModel : ViewModel() {
|
||||
private val matrix = MatrixInstance.getInstance()
|
||||
|
|
@ -11,7 +13,22 @@ class MainViewModel : ViewModel() {
|
|||
return matrix.isLoggedIn().first()
|
||||
}
|
||||
|
||||
fun startSyncIfLogged(){
|
||||
viewModelScope.launch {
|
||||
if(!isLoggedIn()) return@launch
|
||||
matrix.activeClient().startSync()
|
||||
}
|
||||
}
|
||||
|
||||
fun stopSyncIfLogged(){
|
||||
viewModelScope.launch {
|
||||
if (!isLoggedIn()) return@launch
|
||||
matrix.activeClient().stopSync()
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun restoreSession() {
|
||||
matrix.restoreSession()
|
||||
matrix.activeClient().startSync()
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue