Skip to content

Commit

Permalink
A fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Mihai-Cristian Condrea committed Nov 3, 2024
1 parent 37d85a8 commit 494abe9
Showing 1 changed file with 24 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,21 @@ class HomeViewModel(application : Application) : BaseViewModel(application) {
fileSelectionMap = updatedFileSelectionStates ,
selectedFilesCount = newSelectedCount ,
areAllFilesSelected = when {
newSelectedCount == currentUiState.analyzeState.scannedFileList.size && newSelectedCount > 0 -> true
newSelectedCount == 0 -> false
isChecked -> currentUiState.analyzeState.areAllFilesSelected
else -> false
newSelectedCount == currentUiState.analyzeState.scannedFileList.size && newSelectedCount > 0 -> {
true
}

newSelectedCount == 0 -> {
false
}

isChecked -> {
currentUiState.analyzeState.areAllFilesSelected
}

else -> {
false
}
}
)
)
Expand All @@ -170,14 +181,17 @@ class HomeViewModel(application : Application) : BaseViewModel(application) {
val newState = ! _uiState.value.analyzeState.areAllFilesSelected
_uiState.update { currentUiState ->
currentUiState.copy(analyzeState = currentUiState.analyzeState.copy(areAllFilesSelected = newState ,
fileSelectionMap = if (newState) {
currentUiState.analyzeState.scannedFileList.associateWith { true }
}
else {
emptyMap()
fileSelectionMap = when {
newState -> {
(currentUiState.analyzeState.scannedFileList + currentUiState.analyzeState.emptyFolderList).associateWith { true }
}

else -> {
emptyMap()
}
} ,
selectedFilesCount = if (newState) {
currentUiState.analyzeState.scannedFileList.size
(currentUiState.analyzeState.scannedFileList.size + currentUiState.analyzeState.emptyFolderList.size)
}
else {
0
Expand Down

0 comments on commit 494abe9

Please sign in to comment.