From 93ee04cda874573e7cb21ea4b5f49f9066b4ad0a Mon Sep 17 00:00:00 2001 From: Kevin Schildhorn Date: Fri, 11 Oct 2024 13:30:48 -0400 Subject: [PATCH] removing loggedIn --- .../fotopresenter/ui/screens/directory/DirectoryScreen.kt | 1 - .../ui/screens/directory/DirectoryScreenState.kt | 1 - .../ui/screens/directory/DirectoryViewModel.kt | 6 ------ .../fotopresenter/ui/viewmodel/DirectoryViewModelTest.kt | 4 ---- 4 files changed, 12 deletions(-) diff --git a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/screens/directory/DirectoryScreen.kt b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/screens/directory/DirectoryScreen.kt index ab3ee5a1..277bafb4 100644 --- a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/screens/directory/DirectoryScreen.kt +++ b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/screens/directory/DirectoryScreen.kt @@ -69,7 +69,6 @@ fun DirectoryScreen( var overlayVisible by remember { mutableStateOf(DirectoryOverlay.NONE) } // Navigation - if (!uiState.loggedIn) onLogout() uiState.slideshowDetails?.let { onStartSlideshow(it) } diff --git a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/screens/directory/DirectoryScreenState.kt b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/screens/directory/DirectoryScreenState.kt index 7c4062f1..f2ee82b1 100644 --- a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/screens/directory/DirectoryScreenState.kt +++ b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/screens/directory/DirectoryScreenState.kt @@ -13,7 +13,6 @@ data class DirectoryScreenState( val currentPath: String = "", var directoryGridState: DirectoryGridState = DirectoryGridState(emptyList(), mutableListOf()), val slideshowDetails: ImageSlideshowDetails? = null, - val loggedIn: Boolean = true, val selectedDirectory: DirectoryGridCellState? = null, val currentImageCount: Int = 0, val totalImageCount: Int = 0, diff --git a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/screens/directory/DirectoryViewModel.kt b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/screens/directory/DirectoryViewModel.kt index 4be35edf..04b60cef 100644 --- a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/screens/directory/DirectoryViewModel.kt +++ b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/screens/directory/DirectoryViewModel.kt @@ -74,18 +74,12 @@ class DirectoryViewModel( //region Connection - fun setLoggedIn() { - _uiState.update { it.copy(loggedIn = true) } - } - fun logout() { cancelJobs() viewModelScope.launch(Dispatchers.Default) { logger.i { "Logging Out" } val logoutUseCase = UseCaseFactory.disconnectFromServerUseCase logoutUseCase() - logger.d { "Setting loggedIn state to false" } - _uiState.update { it.copy(loggedIn = false) } } } diff --git a/shared/src/commonTest/kotlin/com/kevinschildhorn/fotopresenter/ui/viewmodel/DirectoryViewModelTest.kt b/shared/src/commonTest/kotlin/com/kevinschildhorn/fotopresenter/ui/viewmodel/DirectoryViewModelTest.kt index 336393b7..4c08a34b 100644 --- a/shared/src/commonTest/kotlin/com/kevinschildhorn/fotopresenter/ui/viewmodel/DirectoryViewModelTest.kt +++ b/shared/src/commonTest/kotlin/com/kevinschildhorn/fotopresenter/ui/viewmodel/DirectoryViewModelTest.kt @@ -54,7 +54,6 @@ class DirectoryViewModelTest : KoinTest { fun `Refresh Screen`() = runTest(testDispatcher) { val viewModel: DirectoryViewModel by inject() - assertTrue(viewModel.uiState.value.loggedIn) viewModel.uiState.test { viewModel.refreshScreen() @@ -68,7 +67,6 @@ class DirectoryViewModelTest : KoinTest { state = awaitItem() assertEquals(UiState.SUCCESS, state.state) assertEquals("", state.currentPath) - assertTrue(state.loggedIn) assertEquals(2, state.directoryGridState.imageStates.count()) assertEquals(2, state.directoryGridState.folderStates.count()) cancelAndIgnoreRemainingEvents() @@ -79,12 +77,10 @@ class DirectoryViewModelTest : KoinTest { fun logout() = runTest(testDispatcher) { val viewModel: DirectoryViewModel by inject() - assertTrue(viewModel.uiState.value.loggedIn) viewModel.uiState.test { var state = awaitItem() viewModel.logout() state = awaitItem() - assertFalse(state.loggedIn) cancelAndIgnoreRemainingEvents() } }