refactor: rename View into Section to keep coherence

This commit is contained in:
Edouard Vanbelle
2026-04-02 20:44:06 +02:00
parent 8d2a45c0ff
commit db30639823
4 changed files with 30 additions and 28 deletions
+13 -13
View File
@@ -283,31 +283,31 @@ function switchSectionTo(section) {
switch (section) { switch (section) {
case "files": case "files":
switchToFilesView(); switchToFilesSection();
case "shared": case "shared":
switchToSharedView(); switchToSharedSection();
break; break;
case "recent": case "recent":
switchToRecentFilesView(); switchToRecentFilesSection();
break; break;
case "favorites": case "favorites":
switchToFavoritesView(); switchToFavoritesSection();
break; break;
case "photos": case "photos":
switchToPhotosView(); switchToPhotosSection();
break; break;
case "trash": case "trash":
switchToTrashView(); switchToTrashSection();
break; break;
default: default:
console.warn(`context view ${section} unkonwn fallback to drive section`); console.warn(`context view ${section} unkonwn fallback to drive section`);
switchToFilesView(); switchToFilesSection();
} }
} }
@@ -586,30 +586,30 @@ function setupEventListeners() {
switch(itemI18nKey) { switch(itemI18nKey) {
case 'nav.shared': case 'nav.shared':
// Switch to shared view // Switch to shared view
switchToSharedView(); switchToSharedSection();
break; break;
case 'nav.favorites': case 'nav.favorites':
// Switch to favorites view // Switch to favorites view
switchToFavoritesView(); switchToFavoritesSection();
break; break;
case 'nav.recent': case 'nav.recent':
// Switch to recent files view // Switch to recent files view
switchToRecentFilesView(); switchToRecentFilesSection();
break; break;
case 'nav.photos': case 'nav.photos':
switchToPhotosView(); switchToPhotosSection();
break; break;
case 'nav.trash': case 'nav.trash':
switchToTrashView(); switchToTrashSection();
break; break;
default: default:
// Use the proper switchToFilesView function which handles all UI restoration // Use the proper switchToFilesView function which handles all UI restoration
window.switchToFilesView(); window.switchToFilesSection();
// FIXME: because fileview handles it: need to converge code // FIXME: because fileview handles it: need to converge code
_updateHistory = false; _updateHistory = false;
} }
+14 -12
View File
@@ -156,7 +156,7 @@ function setCurrentSection(section) {
return true; return true;
} }
function switchToSharedView() { function switchToSharedSection() {
if (!setCurrentSection('shared')) return; if (!setCurrentSection('shared')) return;
@@ -181,7 +181,7 @@ function switchToSharedView() {
} }
} }
function switchToFilesView() { function switchToFilesSection() {
if (!setCurrentSection('files')) return; if (!setCurrentSection('files')) return;
// Set actions bar mode // Set actions bar mode
@@ -206,7 +206,7 @@ function switchToFilesView() {
window.loadFiles(); window.loadFiles();
} }
function switchToFavoritesView() { function switchToFavoritesSection() {
if (!setCurrentSection('favorites')) return; if (!setCurrentSection('favorites')) return;
// Set actions bar mode // Set actions bar mode
@@ -239,7 +239,7 @@ function switchToFavoritesView() {
} }
} }
function switchToRecentFilesView() { function switchToRecentFilesSection() {
if (!setCurrentSection('recent')) return; if (!setCurrentSection('recent')) return;
// Set actions bar mode // Set actions bar mode
@@ -272,7 +272,7 @@ function switchToRecentFilesView() {
} }
} }
function switchToPhotosView() { function switchToPhotosSection() {
if (!setCurrentSection('photos')) return; if (!setCurrentSection('photos')) return;
// Hide breadcrumb // Hide breadcrumb
@@ -294,7 +294,7 @@ function switchToPhotosView() {
} }
} }
function switchToTrashView() { function switchToTrashSection() {
setCurrentSection('trash'); setCurrentSection('trash');
// Hide breadcrumb (only shown in Files view) // Hide breadcrumb (only shown in Files view)
@@ -311,11 +311,13 @@ function switchToTrashView() {
// Load trash items // Load trash items
window.loadTrashItems(); window.loadTrashItems();
if (window.multiSelect) window.multiSelect.clear();
} }
window.switchToFilesView = switchToFilesView; window.switchToFilesSection = switchToFilesSection;
window.switchToSharedView = switchToSharedView; window.switchToSharedSection = switchToSharedSection;
window.switchToFavoritesView = switchToFavoritesView; window.switchToFavoritesSection = switchToFavoritesSection;
window.switchToRecentFilesView = switchToRecentFilesView; window.switchToRecentFilesSection = switchToRecentFilesSection;
window.switchToPhotosView = switchToPhotosView; window.switchToPhotosSection = switchToPhotosSection;
window.switchToTrashView = switchToTrashView; window.switchToTrashSection = switchToTrashSection;
+2 -2
View File
@@ -188,8 +188,8 @@ const fileSharing = {
const span = item.querySelector('span'); const span = item.querySelector('span');
if (span && span.getAttribute('data-i18n') === 'nav.shared') { if (span && span.getAttribute('data-i18n') === 'nav.shared') {
item.addEventListener('click', () => { item.addEventListener('click', () => {
if (window.switchToSharedView) { if (window.switchToSharedSection) {
window.switchToSharedView(); window.switchToSharedSection();
} }
}); });
} }
+1 -1
View File
@@ -243,7 +243,7 @@ const sharedView = {
const goToFilesBtn = document.getElementById('go-to-files-btn'); const goToFilesBtn = document.getElementById('go-to-files-btn');
if (goToFilesBtn) { if (goToFilesBtn) {
goToFilesBtn.addEventListener('click', () => { goToFilesBtn.addEventListener('click', () => {
if (window.switchToFilesView) window.switchToFilesView(); if (window.switchToFilesSection) window.switchToFilesSection();
}); });
} }
}, },