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
|
|
@ -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