Skip to content

Commit

Permalink
Fixed some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Mihai-Cristian Condrea committed Oct 18, 2024
1 parent 943357a commit 6cea85f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ class HomeViewModel(application : Application) : BaseViewModel(application) {
fun rescanFiles() {
viewModelScope.launch(context = Dispatchers.Default + coroutineExceptionHandler) {
showLoading()
// Clear previous scan results before starting a new scan
_uiState.update { currentUiState ->
currentUiState.copy(
analyzeState = currentUiState.analyzeState.copy(
Expand Down Expand Up @@ -181,16 +180,15 @@ class HomeViewModel(application : Application) : BaseViewModel(application) {
showLoading()
repository.deleteFiles(filesToDelete) {
_uiState.update { currentUiState ->
currentUiState.copy(
analyzeState = currentUiState.analyzeState.copy(
scannedFileList = currentUiState.analyzeState.scannedFileList.filterNot {
filesToDelete.contains(it)
} ,
selectedFilesCount = 0 ,
areAllFilesSelected = false ,
fileSelectionMap = emptyMap()
)
)
currentUiState.copy(analyzeState = currentUiState.analyzeState.copy(
scannedFileList = currentUiState.analyzeState.scannedFileList.filterNot {
filesToDelete.contains(it)
} ,
selectedFilesCount = 0 ,
areAllFilesSelected = false ,
fileSelectionMap = emptyMap() ,
isAnalyzeScreenVisible = false ,
))
}
updateStorageInfo()
}
Expand All @@ -208,16 +206,13 @@ class HomeViewModel(application : Application) : BaseViewModel(application) {
showLoading()
repository.moveToTrash(filesToMove) {
_uiState.update { currentUiState ->
currentUiState.copy(
analyzeState = currentUiState.analyzeState.copy(
scannedFileList = currentUiState.analyzeState.scannedFileList.filterNot { existingFile ->
filesToMove.any { movedFile -> existingFile.absolutePath == movedFile.absolutePath }
} ,
selectedFilesCount = 0 ,
areAllFilesSelected = false ,
fileSelectionMap = emptyMap()
)
)
currentUiState.copy(analyzeState = currentUiState.analyzeState.copy(
scannedFileList = currentUiState.analyzeState.scannedFileList.filterNot { existingFile ->
filesToMove.any { movedFile -> existingFile.absolutePath == movedFile.absolutePath }
} ,
selectedFilesCount = 0 ,
areAllFilesSelected = false ,
fileSelectionMap = emptyMap()))
}
updateStorageInfo()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.d4rk.cleaner.ui.screens.home.repository

import android.app.Application
import android.os.Environment
import android.util.Log
import com.d4rk.cleaner.data.datastore.DataStore
import com.d4rk.cleaner.data.model.ui.screens.FileTypesData
import com.d4rk.cleaner.data.model.ui.screens.UiHomeModel
Expand Down

0 comments on commit 6cea85f

Please sign in to comment.