Skip to content
Snippets Groups Projects
Verified Commit bb66a02c authored by Sebastian's avatar Sebastian Committed by Mikolai Gütschow
Browse files

Don't show the back button when startup fails

parent 7f4aad41
No related branches found
No related tags found
1 merge request!301Don't show the back button when startup fails
Pipeline #13737 failed
/* /*
* Briar Desktop * Briar Desktop
* Copyright (C) 2021-2022 The Briar Project * Copyright (C) 2021-2023 The Briar Project
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
...@@ -21,7 +21,7 @@ package org.briarproject.briar.desktop.login ...@@ -21,7 +21,7 @@ package org.briarproject.briar.desktop.login
class ErrorSubViewModel( class ErrorSubViewModel(
private val viewModel: StartupViewModel, private val viewModel: StartupViewModel,
val error: Error, val error: Error,
val onBackButton: (() -> Unit)?, val onBackButton: (() -> Unit)? = null,
) : StartupViewModel.SubViewModel { ) : StartupViewModel.SubViewModel {
sealed interface Error sealed interface Error
} }
/* /*
* Briar Desktop * Briar Desktop
* Copyright (C) 2021-2022 The Briar Project * Copyright (C) 2021-2023 The Briar Project
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
...@@ -122,7 +122,7 @@ class RegistrationSubViewModel( ...@@ -122,7 +122,7 @@ class RegistrationSubViewModel(
viewModel.startBriarCore() viewModel.startBriarCore()
} else { } else {
LOG.w { "Failed to create account" } LOG.w { "Failed to create account" }
viewModel.showError(RegistrationError) viewModel.showError(RegistrationError, true)
} }
} }
} }
......
/* /*
* Briar Desktop * Briar Desktop
* Copyright (C) 2021-2022 The Briar Project * Copyright (C) 2021-2023 The Briar Project
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
...@@ -82,12 +82,16 @@ constructor( ...@@ -82,12 +82,16 @@ constructor(
_currentSubViewModel.value = makeRegistration() _currentSubViewModel.value = makeRegistration()
} }
private fun makeError(error: ErrorSubViewModel.Error) = ErrorSubViewModel( private fun makeError(error: ErrorSubViewModel.Error, allowBackNavigation: Boolean): ErrorSubViewModel {
this, error, onBackButton = { _currentSubViewModel.value = decideSubViewModel() } return if (allowBackNavigation) {
) ErrorSubViewModel(this, error, onBackButton = { _currentSubViewModel.value = decideSubViewModel() })
} else {
ErrorSubViewModel(this, error)
}
}
fun showError(error: ErrorSubViewModel.Error) { fun showError(error: ErrorSubViewModel.Error, allowBackNavigation: Boolean) {
_currentSubViewModel.value = makeError(error) _currentSubViewModel.value = makeError(error, allowBackNavigation)
} }
private fun makeAbout(previous: SubViewModel) = private fun makeAbout(previous: SubViewModel) =
...@@ -110,7 +114,7 @@ constructor( ...@@ -110,7 +114,7 @@ constructor(
ALREADY_RUNNING -> LOG.i { "Already running" } ALREADY_RUNNING -> LOG.i { "Already running" }
else -> { else -> {
LOG.w { "Startup failed: $result" } LOG.w { "Startup failed: $result" }
showError(StartingError(result)) showError(StartingError(result), false)
} }
} }
} }
......
/* /*
* Briar Desktop * Briar Desktop
* Copyright (C) 2021-2022 The Briar Project * Copyright (C) 2021-2023 The Briar Project
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
*/ */
@file:Suppress("HardCodedStringLiteral") @file:Suppress("HardCodedStringLiteral")
package org.briarproject.briar.desktop package org.briarproject.briar.desktop
import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.LaunchedEffect
...@@ -24,6 +25,8 @@ import androidx.compose.ui.ExperimentalComposeUiApi ...@@ -24,6 +25,8 @@ import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.window.application import androidx.compose.ui.window.application
import mu.KotlinLogging import mu.KotlinLogging
import org.briarproject.bramble.BrambleCoreEagerSingletons import org.briarproject.bramble.BrambleCoreEagerSingletons
import org.briarproject.bramble.api.lifecycle.Service
import org.briarproject.bramble.api.lifecycle.ServiceException
import org.briarproject.briar.BriarCoreEagerSingletons import org.briarproject.briar.BriarCoreEagerSingletons
import org.briarproject.briar.desktop.TestUtils.getDataDir import org.briarproject.briar.desktop.TestUtils.getDataDir
import org.briarproject.briar.desktop.utils.KLoggerUtils.i import org.briarproject.briar.desktop.utils.KLoggerUtils.i
...@@ -37,6 +40,7 @@ internal class RunWithTemporaryAccount( ...@@ -37,6 +40,7 @@ internal class RunWithTemporaryAccount(
val createAccount: Boolean = true, val createAccount: Boolean = true,
val login: Boolean = true, val login: Boolean = true,
val makeDirUnwritable: Boolean = false, val makeDirUnwritable: Boolean = false,
val addBrokenService: Boolean = false,
val customization: BriarDesktopTestApp.() -> Unit = {}, val customization: BriarDesktopTestApp.() -> Unit = {},
) { ) {
...@@ -78,6 +82,16 @@ internal class RunWithTemporaryAccount( ...@@ -78,6 +82,16 @@ internal class RunWithTemporaryAccount(
val lifecycleManager = app.getLifecycleManager() val lifecycleManager = app.getLifecycleManager()
val accountManager = app.getAccountManager() val accountManager = app.getAccountManager()
if (addBrokenService) {
lifecycleManager.registerService(object : Service {
override fun startService() {
throw ServiceException()
}
override fun stopService() {}
})
}
if (createAccount) { if (createAccount) {
val password = "verySecret123!" val password = "verySecret123!"
accountManager.createAccount("alice", password) accountManager.createAccount("alice", password)
......
/*
* Briar Desktop
* Copyright (C) 2023 The Briar Project
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.briarproject.briar.desktop
/*
* Running this scenario will show an error message after account creation.
*/
fun main() = RunWithTemporaryAccount(
createAccount = false,
addBrokenService = true,
).run()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment