From cb89bb9628f6f0532a175db57de4da3005b27263 Mon Sep 17 00:00:00 2001 From: Willy-JL Date: Mon, 13 Feb 2023 05:01:31 +0000 Subject: [PATCH] Fix archive sorting (skip on big folders) --- applications/main/archive/helpers/archive_browser.c | 4 +++- applications/services/gui/modules/file_browser.c | 2 +- applications/services/gui/modules/file_browser_worker.c | 2 +- applications/services/gui/modules/file_browser_worker.h | 2 ++ 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/applications/main/archive/helpers/archive_browser.c b/applications/main/archive/helpers/archive_browser.c index 97a3496f6..c72220c6a 100644 --- a/applications/main/archive/helpers/archive_browser.c +++ b/applications/main/archive/helpers/archive_browser.c @@ -74,7 +74,9 @@ static void archive_list_item_cb( browser->view, ArchiveBrowserViewModel * model, { - files_array_sort(model->files); + if(model->item_cnt <= BROWSER_SORT_THRESHOLD) { + files_array_sort(model->files); + } model->list_loading = false; }, true); diff --git a/applications/services/gui/modules/file_browser.c b/applications/services/gui/modules/file_browser.c index a2778bdd2..0dbd4b8a2 100644 --- a/applications/services/gui/modules/file_browser.c +++ b/applications/services/gui/modules/file_browser.c @@ -478,7 +478,7 @@ static void browser_list_item_cb( browser->view, FileBrowserModel * model, { - if(model->item_cnt < 430) { + if(model->item_cnt <= BROWSER_SORT_THRESHOLD) { FuriString* selected = NULL; if(model->item_idx > 0) { selected = furi_string_alloc_set( diff --git a/applications/services/gui/modules/file_browser_worker.c b/applications/services/gui/modules/file_browser_worker.c index 8e56ab273..9d219429b 100644 --- a/applications/services/gui/modules/file_browser_worker.c +++ b/applications/services/gui/modules/file_browser_worker.c @@ -418,7 +418,7 @@ static int32_t browser_worker(void* context) { if(flags & WorkerEvtLoad) { FURI_LOG_D( TAG, "Load offset: %lu cnt: %lu", browser->load_offset, browser->load_count); - if(items_cnt > 430) { + if(items_cnt > BROWSER_SORT_THRESHOLD) { browser_folder_load_chunked( browser, path, browser->load_offset, browser->load_count); } else { diff --git a/applications/services/gui/modules/file_browser_worker.h b/applications/services/gui/modules/file_browser_worker.h index 19a9337ff..859b11be4 100644 --- a/applications/services/gui/modules/file_browser_worker.h +++ b/applications/services/gui/modules/file_browser_worker.h @@ -7,6 +7,8 @@ extern "C" { #endif +#define BROWSER_SORT_THRESHOLD 400 + typedef struct BrowserWorker BrowserWorker; typedef void (*BrowserWorkerFolderOpenCallback)( void* context,