diff --git a/static/js/app/navigation.js b/static/js/app/navigation.js index 0121d037..9522f8c3 100644 --- a/static/js/app/navigation.js +++ b/static/js/app/navigation.js @@ -118,8 +118,12 @@ function getSectionFromNavItem(navItem) { /** * Set the current active section, updating all view flags and nav UI. * @param {string} section - The section to activate ('files', 'shared', 'recent', 'favorites', 'trash') + * @returns {boolean} true if the section changed */ function setCurrentSection(section) { + + if (window.app.currentSection == section) return false; + // Set all view flags - true for active section, false for others Object.entries(VIEW_FLAGS).forEach(([key, flag]) => { window.app[flag] = (key === section); @@ -148,10 +152,13 @@ function setCurrentSection(section) { if (section !== 'photos' && window.photosView) { window.photosView.hide(); } + + return true; } function switchToSharedView() { - setCurrentSection('shared'); + + if (!setCurrentSection('shared')) return; // Hide breadcrumb (only shown in Files view) const breadcrumb = document.querySelector('.breadcrumb'); @@ -175,7 +182,7 @@ function switchToSharedView() { } function switchToFilesView() { - setCurrentSection('files'); + if (!setCurrentSection('files')) return; // Set actions bar mode window.setActionsBarMode('files', true); @@ -200,7 +207,7 @@ function switchToFilesView() { } function switchToFavoritesView() { - setCurrentSection('favorites'); + if (!setCurrentSection('favorites')) return; // Set actions bar mode window.setActionsBarMode('favorites'); @@ -233,7 +240,7 @@ function switchToFavoritesView() { } function switchToRecentFilesView() { - setCurrentSection('recent'); + if (!setCurrentSection('recent')) return; // Set actions bar mode window.setActionsBarMode('recent'); @@ -266,7 +273,7 @@ function switchToRecentFilesView() { } function switchToPhotosView() { - setCurrentSection('photos'); + if (!setCurrentSection('photos')) return; // Hide breadcrumb const breadcrumb = document.querySelector('.breadcrumb');