diff --git a/static/js/app/authSession.js b/static/js/app/authSession.js
index ffb6f6bc..f756c8b9 100644
--- a/static/js/app/authSession.js
+++ b/static/js/app/authSession.js
@@ -115,7 +115,7 @@ async function checkAuthentication() {
window.location.href = '/login?source=session_expired';
return;
}
- } catch (err) {
+ } catch (_err) {
localStorage.removeItem(USER_DATA_KEY);
window.location.href = '/login?source=session_expired';
return;
@@ -128,9 +128,11 @@ async function checkAuthentication() {
console.log('No cached user data, fetching from server');
try {
const freshData = await refreshUserData();
- if (freshData && freshData.username) {
+ if (freshData?.username) {
const userInitials = freshData.username.substring(0, 2).toUpperCase();
- document.querySelectorAll('.user-avatar, .user-menu-avatar').forEach((el) => (el.textContent = userInitials));
+ document.querySelectorAll('.user-avatar, .user-menu-avatar').forEach((el) => {
+ el.textContent = userInitials;
+ });
window.updateStorageUsageDisplay(freshData);
resolveHomeFolder().then(() => window.loadFiles());
} else {
diff --git a/static/js/app/filesView.js b/static/js/app/filesView.js
index abdee799..4faa2221 100644
--- a/static/js/app/filesView.js
+++ b/static/js/app/filesView.js
@@ -35,7 +35,7 @@ async function getFolder(id) {
cache: 'no-store'
};
- let folderInformations = await fetch(`/api/folders/${id}`, requestOptions);
+ const folderInformations = await fetch(`/api/folders/${id}`, requestOptions);
if (folderInformations.ok) {
return folderInformations.json();
} else {
@@ -67,7 +67,7 @@ async function rebuildBreadCrumb() {
while (id !== null) {
console.log(`fetching folder information for folder ${id}`);
try {
- let folderInfo = await getFolder(id);
+ const folderInfo = await getFolder(id);
// store the Leaf which is the current folder
if (currentFolderInfo === null) {
@@ -84,7 +84,7 @@ async function rebuildBreadCrumb() {
// iterate to parent folder
id = folderInfo.parent_id;
- } catch (e) {
+ } catch (_e) {
console.log(`Error loading information from folder ${app.currentPath}, falling back to ${app.userHomeFolderId}`);
// fallback of root
window.uiNotifications.show(
@@ -110,7 +110,6 @@ async function rebuildBreadCrumb() {
*/
async function loadFiles(options = { insertHistory: true }) {
const app = window.app;
- const elements = window.appElements;
try {
console.log('Starting loadFiles() - loading files...', options);
@@ -125,7 +124,7 @@ async function loadFiles(options = { insertHistory: true }) {
window.isLoadingFiles = true;
// This to avoid blinking page, a better solution would be to put loading on an overlay and remove timeout
- let loadingFiles = setTimeout(() => {
+ const loadingFiles = setTimeout(() => {
// display loader after few delay (will be canceled if result take less time)
window.ui.showError(`
@@ -139,7 +138,7 @@ async function loadFiles(options = { insertHistory: true }) {
await window.resolveHomeFolder();
}
- const timestamp = new Date().getTime();
+ const timestamp = Math.floor(Date.now() / 1000);
await rebuildBreadCrumb();
@@ -181,7 +180,6 @@ async function loadFiles(options = { insertHistory: true }) {
if (forceRefresh) {
url += `&force_refresh=true`;
- // @ts-ignore
requestOptions.headers['X-Force-Refresh'] = 'true';
console.log('Forcing complete refresh ignoring cache');
}
@@ -226,7 +224,7 @@ async function loadFiles(options = { insertHistory: true }) {
let fileFound = null;
// lookup for the given fle
- for( const file of fileList) {
+ for (const file of fileList) {
if (file.id === window.app.viewFile) {
fileFound = file;
break;
@@ -236,14 +234,13 @@ async function loadFiles(options = { insertHistory: true }) {
if (fileFound) {
console.log(`file ${window.app.viewFile} found, calling viewer`);
await window.inlineViewer.openFile(fileFound);
- }
- else {
+ } else {
// remove file
console.log(`file ${window.app.viewFile} not found`);
window.app.viewFile = null;
// correct url/history as file is not found
- window.updateHistory( false);
+ window.updateHistory(false);
}
}
}
diff --git a/static/js/app/main.js b/static/js/app/main.js
index d0414757..7b90552f 100644
--- a/static/js/app/main.js
+++ b/static/js/app/main.js
@@ -126,7 +126,7 @@ function setActionsBarMode(mode, force = false) {
elements.gridViewBtn = document.getElementById('grid-view-btn');
elements.listViewBtn = document.getElementById('list-view-btn');
- if (window.i18n && window.i18n.translateElement) {
+ if (window.i18n?.translateElement) {
window.i18n.translateElement(elements.actionsBar);
}
@@ -231,8 +231,8 @@ function deserializeHash() {
if (hash_elements[1] === 'files' && hash_elements[2] === 'folder' && hash_elements[3] !== null) {
hashContext.path = hash_elements[3];
-
- if (hash_elements[4] == 'file' && hash_elements[5] !== null) {
+
+ if (hash_elements[4] === 'file' && hash_elements[5] !== null) {
hashContext.file = hash_elements[5];
}
}
@@ -248,7 +248,7 @@ function deserializeHash() {
function updateHistory(insertHistory) {
const app = window.app;
- let historyData = {
+ const historyData = {
section: app.currentSection,
id: app.currentFolder,
file: app.viewFile
@@ -261,7 +261,7 @@ function updateHistory(insertHistory) {
historyUrl = historyUrl.concat('/folder/', app.currentFolderInfo.id);
if (window.app.viewFile) {
- historyUrl = historyUrl.concat('/file/', window.app.viewFile);
+ historyUrl = historyUrl.concat('/file/', window.app.viewFile);
}
// update title
document.title = `OxiCloud: ${app.currentFolderInfo.path}`;
@@ -325,7 +325,7 @@ function initApp() {
cacheElements();
// Initialize file sharing module first
- if (window.fileSharing && window.fileSharing.init) {
+ if (window.fileSharing?.init) {
window.fileSharing.init();
} else {
console.warn('fileSharing module not fully initialized');
@@ -349,7 +349,7 @@ function initApp() {
}
// Initialize favorites module if available
- if (window.favorites && window.favorites.init) {
+ if (window.favorites?.init) {
console.log('Initializing favorites module');
window.favorites.init();
} else {
@@ -357,7 +357,7 @@ function initApp() {
}
// Initialize recent files module if available
- if (window.recent && window.recent.init) {
+ if (window.recent?.init) {
console.log('Initializing recent files module');
window.recent.init();
} else {
@@ -365,21 +365,21 @@ function initApp() {
}
// Initialize multi-select / batch actions
- if (window.multiSelect && window.multiSelect.init) {
+ if (window.multiSelect?.init) {
console.log('Initializing multi-select module');
window.multiSelect.init();
}
window.addEventListener('authenticationDone', () => {
// Check if a context was provided in the URL
- let hashContext = deserializeHash();
+ const hashContext = deserializeHash();
switchSectionTo(hashContext.section);
if (hashContext.section === 'files') {
if (hashContext.path) {
console.log(`init: reusing folder from hash URL: ${hashContext.path}`);
window.app.currentPath = hashContext.path;
}
-
+
if (hashContext.file !== null) {
window.app.viewFile = hashContext.file;
}
@@ -388,7 +388,7 @@ function initApp() {
});
// Wait for translations to load before checking authentication
- if (window.i18n && window.i18n.isLoaded && window.i18n.isLoaded()) {
+ if (window.i18n?.isLoaded?.()) {
// Translations already loaded, proceed with authentication
window.checkAuthentication();
} else {
@@ -401,7 +401,7 @@ function initApp() {
// Set a timeout as a fallback in case translations take too long
setTimeout(() => {
- if (!window.i18n || !window.i18n.isLoaded || !window.i18n.isLoaded()) {
+ if (!window.i18n?.isLoaded?.()) {
console.warn('Translations loading timeout, proceeding with authentication anyway');
window.checkAuthentication();
}
@@ -451,7 +451,9 @@ function setupUploadDropdown() {
e.stopPropagation();
const isOpen = menu.classList.contains('show');
// Close any other open dropdowns
- document.querySelectorAll('.upload-dropdown-menu.show').forEach((m) => m.classList.remove('show'));
+ document.querySelectorAll('.upload-dropdown-menu.show').forEach((m) => {
+ m.classList.remove('show');
+ });
if (!isOpen) {
menu.classList.add('show');
}
@@ -462,14 +464,14 @@ function setupUploadDropdown() {
// Close dropdown when clicking outside
// remove+add stable handler: guarantees exactly one global listener
if (uploadDropdownDocumentClickHandler) {
- // @ts-ignore
document.removeEventListener('click', uploadDropdownDocumentClickHandler);
}
uploadDropdownDocumentClickHandler = (e) => {
if (e.target.closest('#upload-dropdown')) return;
- document.querySelectorAll('.upload-dropdown-menu.show').forEach((m) => m.classList.remove('show'));
+ document.querySelectorAll('.upload-dropdown-menu.show').forEach((m) => {
+ m.classList.remove('show');
+ });
};
- // @ts-ignore
document.addEventListener('click', uploadDropdownDocumentClickHandler);
}
@@ -587,13 +589,15 @@ function setupEventListeners() {
elements.navItems.forEach((item) => {
item.addEventListener('click', () => {
// Remove active class from all nav items
- elements.navItems.forEach((navItem) => navItem.classList.remove('active'));
+ elements.navItems.forEach((navItem) => {
+ navItem.classList.remove('active');
+ });
// Add active class to clicked item
item.classList.add('active');
let _updateHistory = true;
- let itemI18nKey = item.querySelector('span').getAttribute('data-i18n');
+ const itemI18nKey = item.querySelector('span').getAttribute('data-i18n');
switch (itemI18nKey) {
case 'nav.shared':
// Switch to shared view
@@ -712,7 +716,7 @@ function updateStorageUsageDisplay(userData) {
storageInfo.removeAttribute('data-i18n');
// Use i18n if available
- if (window.i18n && window.i18n.t) {
+ if (window.i18n?.t) {
storageInfo.textContent = window.i18n.t('storage.used', {
percentage: usagePercentage,
used: usedFormatted,
diff --git a/static/js/app/navigation.js b/static/js/app/navigation.js
index 2ebf9643..6cd52d19 100644
--- a/static/js/app/navigation.js
+++ b/static/js/app/navigation.js
@@ -127,7 +127,7 @@ function getSectionFromNavItem(navItem) {
* @returns {boolean} true if the section changed
*/
function setCurrentSection(section) {
- if (window.app.currentSection == section) return false;
+ 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]) => {
diff --git a/static/js/app/searchView.js b/static/js/app/searchView.js
index 7f687d40..2dfcfc85 100644
--- a/static/js/app/searchView.js
+++ b/static/js/app/searchView.js
@@ -42,7 +42,7 @@ async function performSearch(query, sortBy) {
document.addEventListener('search-resort', (e) => {
const searchInput = document.querySelector('.search-container input');
- if (searchInput && searchInput.value.trim()) {
+ if (searchInput?.value.trim()) {
performSearch(searchInput.value.trim(), e.detail.sort_by);
}
});
diff --git a/static/js/app/trashView.js b/static/js/app/trashView.js
index 065e13c9..9ad63788 100644
--- a/static/js/app/trashView.js
+++ b/static/js/app/trashView.js
@@ -8,7 +8,7 @@ async function loadTrashItems() {
try {
if (window.multiSelect) window.multiSelect.clear();
window.ui.resetFilesList(); // ensure also list visible & error hidden
- const _tt = window.i18n && window.i18n.t ? window.i18n.t : (k) => k.split('.').pop();
+ const _tt = window.i18n?.t ? window.i18n.t : (k) => k.split('.').pop();
elements.filesList.innerHTML = `