style: apply linter suggestions

This commit is contained in:
Edouard Vanbelle
2026-04-07 22:50:42 +02:00
parent 1ce29c101d
commit a4266a6e93
33 changed files with 444 additions and 437 deletions
+3 -3
View File
@@ -104,7 +104,7 @@ const favorites = {
await this._fetchFromServer();
// Notify user
if (window.ui && window.ui.showNotification) {
if (window.ui?.showNotification) {
window.ui.showNotification(
window.i18n ? window.i18n.t('favorites.added_title') : 'Added to favorites',
`"${name}" ${window.i18n ? window.i18n.t('favorites.added_msg') : 'added to favorites'}`
@@ -139,7 +139,7 @@ const favorites = {
// Remove from local cache
this._cache.delete(this._cacheKey(id, type));
if (window.ui && window.ui.showNotification) {
if (window.ui?.showNotification) {
window.ui.showNotification(
window.i18n ? window.i18n.t('favorites.removed_title') : 'Removed from favorites',
`"${itemName}" ${window.i18n ? window.i18n.t('favorites.removed_msg') : 'removed from favorites'}`
@@ -208,7 +208,7 @@ const favorites = {
if (files.length) window.ui.renderFiles(files);
} catch (error) {
console.error('Error displaying favorites:', error);
if (window.ui && window.ui.showNotification) {
if (window.ui?.showNotification) {
window.ui.showNotification('Error', 'Error loading favorite items');
}
}
+6 -4
View File
@@ -207,7 +207,7 @@ const photosView = {
if (existingHeader) {
// Append tiles to existing grid and update count badge
const grid = existingHeader.nextElementSibling;
if (grid && grid.classList.contains('photos-grid')) {
if (grid?.classList.contains('photos-grid')) {
grid.insertAdjacentHTML('beforeend', tilesHtml);
const countSpan = existingHeader.querySelector('.photos-day-count');
if (countSpan) countSpan.textContent = grid.children.length;
@@ -228,7 +228,7 @@ const photosView = {
/** Generate HTML for a single photo/video tile */
_renderTile(file) {
const isVideo = file.mime_type && file.mime_type.startsWith('video/');
const isVideo = file.mime_type?.startsWith('video/');
const selected = this.selected.has(file.id) ? ' selected' : '';
const cachedThumb = isVideo && this._videoThumbCache.has(file.id) ? this._videoThumbCache.get(file.id) : null;
const thumbUrl = cachedThumb || `/api/files/${file.id}/thumbnail/preview`;
@@ -359,7 +359,7 @@ const photosView = {
// Upload to server for permanent caching
const token = localStorage.getItem('token') || sessionStorage.getItem('token');
const headers = { 'Content-Type': blob.type, ...getCsrfHeaders() };
if (token) headers['Authorization'] = `Bearer ${token}`;
if (token) headers.Authorization = `Bearer ${token}`;
fetch(`/api/files/${fileId}/thumbnail/preview`, {
method: 'PUT',
@@ -527,7 +527,9 @@ const photosView = {
bar.querySelector('#photos-sel-clear').onclick = () => {
this.selected.clear();
this._container.querySelectorAll('.photo-tile.selected').forEach((t) => t.classList.remove('selected'));
this._container.querySelectorAll('.photo-tile.selected').forEach((t) => {
t.classList.remove('selected');
});
this._hideSelectionBar();
};
+3 -3
View File
@@ -139,7 +139,7 @@ const photosLightbox = {
content.innerHTML = '<div class="photos-loading"><i class="fas fa-spinner"></i></div>';
try {
const isVideo = item.mime_type && item.mime_type.startsWith('video/');
const isVideo = item.mime_type?.startsWith('video/');
const res = await fetch(`/api/files/${item.id}`, {
credentials: 'include',
headers: this._headers()
@@ -172,7 +172,7 @@ const photosLightbox = {
});
if (res.ok) {
const data = await res.json();
let parts = [dateStr];
const parts = [dateStr];
if (sizeStr) parts.push(sizeStr);
if (data.camera_make || data.camera_model) {
parts.push([data.camera_make, data.camera_model].filter(Boolean).join(' '));
@@ -182,7 +182,7 @@ const photosLightbox = {
}
metaEl.textContent = parts.join(' · ');
}
} catch (err) {
} catch (_err) {
// Non-critical, keep existing meta
}
},
+2 -2
View File
@@ -32,7 +32,7 @@ const recent = {
*/
setupEventListeners() {
document.addEventListener('file-accessed', (event) => {
if (event.detail && event.detail.file) {
if (event.detail?.file) {
const file = event.detail.file;
const itemType = file.item_type || 'file';
this._recordAccess(file.id, itemType);
@@ -144,7 +144,7 @@ const recent = {
if (files.length) window.ui.renderFiles(files);
} catch (error) {
console.error('Error displaying recent files:', error);
if (window.ui && window.ui.showNotification) {
if (window.ui?.showNotification) {
window.ui.showNotification('Error', 'Error loading recent files');
}
}