Skip to content

Commit 66211ff

Browse files
benabelphpbg
andauthored
Exclude subpaths when parentPtah is clicked (#45)
Co-authored-by: Samuel CHEMLA <[email protected]>
1 parent ae0f98c commit 66211ff

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

app/src/main/java/com/phpbg/easysync/ui/AdvancedSyncSettingsViewModel.kt

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,22 @@ class AdvancedSyncSettingsViewModel(application: Application) : AndroidViewModel
7979
viewModelScope.launch {
8080
_advancedSyncSettingsUiState.value?.let { uiState ->
8181
val updatedList = uiState.paths.map {
82-
it.takeIf { it.relativePath != relativePath }
83-
?: SyncPath(relativePath = it.relativePath, enabled = activated)
82+
// Update enabled status for path and sub-paths
83+
if (it.relativePath.startsWith(relativePath)) {
84+
it.copy(enabled = activated)
85+
} else {
86+
it
87+
}
8488
}
8589
_advancedSyncSettingsUiState.postValue(uiState.copy(paths = updatedList))
86-
settingsDataStore.updateExclusionPath(relativePath, !activated)
90+
91+
// Update settings.exclusionPath
92+
uiState.paths.filter { it.relativePath.startsWith(relativePath) }
93+
.forEach { subPath ->
94+
settingsDataStore.updateExclusionPath(
95+
subPath.relativePath, !activated
96+
)
97+
}
8798
}
8899
}
89100
}

0 commit comments

Comments
 (0)