diff --git a/src/main/kotlin/org/briarproject/briar/desktop/BriarService.kt b/src/main/kotlin/org/briarproject/briar/desktop/BriarService.kt index 4dc34b77dfc84fa019a5ae2a6de32b05f5b46984..b78aba7ca3e74bf2ee9f9f898b173bbc450115de 100644 --- a/src/main/kotlin/org/briarproject/briar/desktop/BriarService.kt +++ b/src/main/kotlin/org/briarproject/briar/desktop/BriarService.kt @@ -81,6 +81,7 @@ constructor( var screenState by remember { mutableStateOf( if (accountManager.hasDatabaseKey()) { + loadContacts() Screen.MAIN } else if (accountManager.accountExists()) { Screen.LOGIN @@ -101,6 +102,7 @@ constructor( onSubmit = { username, password -> accountManager.createAccount(username, password) signedIn() + loadContacts() screenState = Screen.MAIN } ) @@ -110,6 +112,7 @@ constructor( try { accountManager.signIn(it) signedIn() + loadContacts() screenState = Screen.MAIN } catch (e: DecryptionException) { // failure, try again @@ -135,6 +138,9 @@ constructor( val dbKey = accountManager.databaseKey ?: throw AssertionError() lifecycleManager.startServices(dbKey) lifecycleManager.waitForStartup() + } + + private fun loadContacts() { val contacts = contactManager.contacts for (contact in contacts) { println("${contact.author.name} (${contact.alias})") diff --git a/src/test/kotlin/org/briarproject/briar/desktop/TestWithTemporaryAccount.kt b/src/test/kotlin/org/briarproject/briar/desktop/TestWithTemporaryAccount.kt index 15d9af08a10d7c82df233c408e71244e23292252..20c9561e431bae0f2cf7180b81bacca2bf9bd958 100644 --- a/src/test/kotlin/org/briarproject/briar/desktop/TestWithTemporaryAccount.kt +++ b/src/test/kotlin/org/briarproject/briar/desktop/TestWithTemporaryAccount.kt @@ -29,16 +29,29 @@ private class TestWithTemporaryAccount { println("Using data directory '$dataDir'") val app = - DaggerBriarDesktopApp.builder().desktopModule( - DesktopModule(dataDir.toFile()) + DaggerBriarDesktopTestApp.builder().desktopTestModule( + DesktopTestModule(dataDir.toFile()) ).build() // We need to load the eager singletons directly after making the // dependency graphs BrambleCoreEagerSingletons.Helper.injectEagerSingletons(app) BriarCoreEagerSingletons.Helper.injectEagerSingletons(app) + val lifecycleManager = app.getLifecycleManager() + val accountManager = app.getAccountManager() + val password = "verySecret123!" - app.getAccountManager().createAccount("alice", password) + accountManager.createAccount("alice", password) + + val dbKey = accountManager.databaseKey ?: throw AssertionError() + lifecycleManager.startServices(dbKey) + lifecycleManager.waitForStartup() + + app.getTestDataCreator().createTestData(10, 20, 50, 4, 4, 10) + + // Creating test data happens on a background thread. As we do not get notified about updates to the conact + // list yet, we need to wait a moment in order for that to finish (hopefully). + Thread.sleep(1000) app.getUI().startBriar() }