diff --git a/app/src/main/java/chat/revolt/screens/SplashScreen.kt b/app/src/main/java/chat/revolt/screens/SplashScreen.kt
index b8aa7c0c..470dc07b 100644
--- a/app/src/main/java/chat/revolt/screens/SplashScreen.kt
+++ b/app/src/main/java/chat/revolt/screens/SplashScreen.kt
@@ -6,6 +6,7 @@ import android.content.Intent
import android.net.ConnectivityManager
import android.net.NetworkCapabilities
import android.util.Log
+import android.widget.Toast
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.foundation.Image
@@ -25,6 +26,7 @@ import androidx.navigation.NavController
import chat.revolt.R
import chat.revolt.activities.WebChallengeActivity
import chat.revolt.api.RevoltAPI
+import chat.revolt.api.RevoltHttp
import chat.revolt.api.internals.WebChallenge
import chat.revolt.api.settings.GlobalState
import chat.revolt.api.settings.SyncedSettings
@@ -34,6 +36,7 @@ import chat.revolt.ui.theme.RevoltColorScheme
import chat.revolt.ui.theme.Theme
import dagger.hilt.android.lifecycle.HiltViewModel
import dagger.hilt.android.qualifiers.ApplicationContext
+import io.ktor.client.request.get
import kotlinx.coroutines.launch
import javax.inject.Inject
@@ -76,6 +79,11 @@ class SplashScreenViewModel @Inject constructor(
}
}
+ private suspend fun canReachRevolt(): Boolean {
+ val res = RevoltHttp.get("/")
+ return res.status.value == 200
+ }
+
fun checkLoggedInState() {
Log.d("SplashScreenViewModel", "Checking logged in state")
viewModelScope.launch {
@@ -92,9 +100,15 @@ class SplashScreenViewModel @Inject constructor(
val token = kvStorage.get("sessionToken") ?: return@launch setNavigateTo("login")
+ val canReachRevolt = canReachRevolt()
val valid = RevoltAPI.checkSessionToken(token)
- if (!valid) {
+ if (canReachRevolt && !valid) {
+ Toast.makeText(
+ context,
+ context.getString(R.string.token_invalid_toast),
+ Toast.LENGTH_SHORT
+ ).show()
kvStorage.remove("sessionToken")
setNavigateTo("login")
} else {
diff --git a/app/src/main/java/chat/revolt/screens/chat/ChatRouterScreen.kt b/app/src/main/java/chat/revolt/screens/chat/ChatRouterScreen.kt
index df9e0d7e..2c126746 100644
--- a/app/src/main/java/chat/revolt/screens/chat/ChatRouterScreen.kt
+++ b/app/src/main/java/chat/revolt/screens/chat/ChatRouterScreen.kt
@@ -212,6 +212,20 @@ fun ChatRouterScreen(topNav: NavController, viewModel: ChatRouterViewModel = hil
}
}
+ LaunchedEffect(RevoltAPI.selfId) {
+ snapshotFlow { RevoltAPI.selfId }
+ .distinctUntilChanged()
+ .collect { selfId ->
+ if (selfId == null) {
+ topNav.popBackStack(
+ topNav.graph.startDestinationRoute!!,
+ inclusive = true
+ )
+ topNav.navigate("splash")
+ }
+ }
+ }
+
ModalBottomSheetLayout(
sheetShape = RoundedCornerShape(topStart = 16.dp, topEnd = 16.dp),
sheetBackgroundColor = MaterialTheme.colorScheme.surface,
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index f0deccbb..d1810402 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -31,7 +31,15 @@
Forgot your password?
Enter your email and we\'ll send you instructions on how to reset your password.
- Let\'s get you started
+ Welcome to Revolt
+ It\'s like a place to hang out, get together, and talk about stuff. Best part, it\'s on the internet.
+ Let\'s get you set up.
+ Your data is safe with us. We don\'t sell it, or use it to show you ads.
+ Email
+ We\'ll send you a verification email to confirm your account.
+ Password
+ Eight or more, common ones are bad. Try messing around with a sentence.
+
Check your mail!
We\'ve sent further instructions to %1$s.
Verify your email, and then we\'ll get on with choosing your username.
@@ -41,6 +49,8 @@
Others will find, recognise and mention you with this name.
But if you change your mind, you can change your username at any time in your User Settings.
+ You have been logged out. Please log in again.
+
One more thing
You\'ve got 2FA enabled to keep your account extra-safe.
Use a one-time password