Skip to content

Commit

Permalink
removing loggedIn
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinSchildhorn committed Oct 11, 2024
1 parent b8e51af commit 93ee04c
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ fun DirectoryScreen(
var overlayVisible by remember { mutableStateOf(DirectoryOverlay.NONE) }

// Navigation
if (!uiState.loggedIn) onLogout()
uiState.slideshowDetails?.let {
onStartSlideshow(it)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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()
}
}
Expand Down

0 comments on commit 93ee04c

Please sign in to comment.