mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 20:36:04 +00:00
fix: a slow folder listing no longer replaces the folder being shown (#1028)
This commit is contained in:
1 parent
6eefcf4267
commit
bdd2485e96
1 file changed
+5
-1
@@ -176,16 +176,20 @@ fun FileManagerScreen(
|
||||
var showFavorites by remember { mutableStateOf(false) }
|
||||
var favTick by remember { mutableIntStateOf(0) }
|
||||
|
||||
var listingJob by remember { mutableStateOf<kotlinx.coroutines.Job?>(null) }
|
||||
|
||||
fun loadDirectory(dir: File, resetScroll: Boolean = true) {
|
||||
currentDir = dir
|
||||
if (pickMode) pickPrefs.edit().putString("lastFilePickerDir", dir.absolutePath).apply()
|
||||
scope.launch {
|
||||
listingJob?.cancel()
|
||||
listingJob = scope.launch {
|
||||
val list = withContext(Dispatchers.IO) {
|
||||
dir.listFiles()?.toList()
|
||||
?.filter { if (pickDirMode) it.isDirectory else !pickMode || it.isDirectory || matchesPickExt(it) }
|
||||
?.filter { showHidden || !it.name.startsWith(".") }
|
||||
?.sortedWith(comparatorFor(sortBy, sortDesc)) ?: emptyList()
|
||||
}
|
||||
if (currentDir != dir) return@launch
|
||||
entries = list
|
||||
if (resetScroll) listState.scrollToItem(0)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user