mirror of
https://github.com/Steffo99/twom.git
synced 2024-11-24 17:14:24 +00:00
Explicitly declare sessions
This commit is contained in:
parent
77dd9373e9
commit
172f4ff76b
3 changed files with 5 additions and 22 deletions
|
@ -8,6 +8,7 @@ import androidx.activity.ComponentActivity
|
|||
import androidx.activity.compose.setContent
|
||||
import androidx.activity.result.contract.ActivityResultContract
|
||||
import eu.steffo.twom.configureroom.components.ConfigureRoomScaffold
|
||||
import eu.steffo.twom.matrix.utils.TwoMMatrix
|
||||
|
||||
|
||||
class ConfigureRoomActivity : ComponentActivity() {
|
||||
|
@ -91,6 +92,7 @@ class ConfigureRoomActivity : ComponentActivity() {
|
|||
|
||||
setContent {
|
||||
ConfigureRoomScaffold(
|
||||
session = TwoMMatrix.session!!,
|
||||
initialConfiguration = configuration,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -7,15 +7,14 @@ import androidx.compose.runtime.CompositionLocalProvider
|
|||
import androidx.compose.ui.Modifier
|
||||
import eu.steffo.twom.configureroom.activities.ConfigureRoomActivity
|
||||
import eu.steffo.twom.matrix.complocals.LocalSession
|
||||
import eu.steffo.twom.matrix.utils.TwoMMatrix
|
||||
import eu.steffo.twom.theme.components.TwoMTheme
|
||||
import org.matrix.android.sdk.api.session.Session
|
||||
|
||||
@Composable
|
||||
fun ConfigureRoomScaffold(
|
||||
session: Session,
|
||||
initialConfiguration: ConfigureRoomActivity.Configuration? = null,
|
||||
) {
|
||||
val session = TwoMMatrix.matrix.authenticationService().getLastAuthenticatedSession()!!
|
||||
|
||||
TwoMTheme {
|
||||
CompositionLocalProvider(LocalSession provides session) {
|
||||
Scaffold(
|
||||
|
|
|
@ -2,14 +2,11 @@ package eu.steffo.twom.viewroom.activities
|
|||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.activity.result.contract.ActivityResultContract
|
||||
import eu.steffo.twom.matrix.utils.TwoMMatrix
|
||||
import eu.steffo.twom.viewroom.components.ViewRoomScaffold
|
||||
import org.matrix.android.sdk.api.session.Session
|
||||
|
||||
class ViewRoomActivity : ComponentActivity() {
|
||||
companion object {
|
||||
|
@ -26,21 +23,6 @@ class ViewRoomActivity : ComponentActivity() {
|
|||
override fun parseResult(resultCode: Int, intent: Intent?) {}
|
||||
}
|
||||
|
||||
private lateinit var session: Session
|
||||
|
||||
private fun fetchLastSession() {
|
||||
Log.d("Main", "Fetching the last successfully authenticated session...")
|
||||
// FIXME: If this is null, it means that something launched this while no session was authenticated...
|
||||
session = TwoMMatrix.matrix.authenticationService().getLastAuthenticatedSession()!!
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
// FIXME: Hopefully, if this succeeds, the session is also open... hopefully.
|
||||
fetchLastSession()
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
|
||||
|
@ -48,7 +30,7 @@ class ViewRoomActivity : ComponentActivity() {
|
|||
|
||||
setContent {
|
||||
ViewRoomScaffold(
|
||||
session = session,
|
||||
session = TwoMMatrix.session!!,
|
||||
roomId = roomId!!,
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue