Properly hide favs tab when no favs are set

This commit is contained in:
Willy-JL
2023-06-04 18:54:39 +01:00
parent 1935e58ff3
commit b63fe76a71
4 changed files with 8 additions and 5 deletions
@@ -484,7 +484,9 @@ void archive_switch_tab(ArchiveBrowserView* browser, InputKey key) {
bool tab_empty = true;
bool is_app_tab = furi_string_start_with_str(browser->path, "/app:");
if(tab == ArchiveTabFavorites) {
tab_empty = false;
if(archive_favorites_count() > 0) {
tab_empty = false;
}
} else if(is_app_tab) {
char* app_name = strchr(furi_string_get_cstr(browser->path), ':');
if(app_name != NULL) {
@@ -46,9 +46,7 @@ static bool archive_favorites_read_line(File* file, FuriString* str_result) {
return result;
}
uint16_t archive_favorites_count(void* context) {
furi_assert(context);
uint16_t archive_favorites_count() {
Storage* fs_api = furi_record_open(RECORD_STORAGE);
File* file = storage_file_alloc(fs_api);
@@ -6,7 +6,7 @@
#define ARCHIVE_FAV_PATH CFG_PATH("favorites.txt")
#define ARCHIVE_FAV_TEMP_PATH CFG_PATH("favorites.tmp")
uint16_t archive_favorites_count(void* context);
uint16_t archive_favorites_count();
bool archive_favorites_read(void* context);
bool archive_favorites_delete(const char* format, ...) _ATTRIBUTE((__format__(__printf__, 1, 2)));
bool archive_is_favorite(const char* format, ...) _ATTRIBUTE((__format__(__printf__, 1, 2)));
@@ -77,6 +77,9 @@ void archive_scene_browser_on_enter(void* context) {
browser->is_root = true;
archive_browser_set_callback(browser, archive_scene_browser_callback, archive);
if(archive_get_tab(browser) == ArchiveTabFavorites && archive_favorites_count() < 1) {
archive_switch_tab(browser, TAB_LEFT);
}
archive_update_focus(browser, archive->text_store);
view_dispatcher_switch_to_view(archive->view_dispatcher, ArchiveViewBrowser);