Fix gallery rename applying to wrong files
After renaming a file, loadDirectory() was called which rebuilt the galleryImages array in new alphabetical order. The gallery index didn't change, so it now pointed to a different file — subsequent renames hit the wrong file. Fix: only update local state during the gallery session, defer the file list refresh to when the gallery closes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -291,6 +291,9 @@ const FileBrowser = {
|
|||||||
const img = document.getElementById('gallery-image');
|
const img = document.getElementById('gallery-image');
|
||||||
if (img.src && img.src.startsWith('blob:')) URL.revokeObjectURL(img.src);
|
if (img.src && img.src.startsWith('blob:')) URL.revokeObjectURL(img.src);
|
||||||
img.src = '';
|
img.src = '';
|
||||||
|
|
||||||
|
// Refresh file list to reflect any renames
|
||||||
|
this.loadDirectory(this.currentPath);
|
||||||
},
|
},
|
||||||
|
|
||||||
async displayGalleryImage(index) {
|
async displayGalleryImage(index) {
|
||||||
@@ -474,9 +477,6 @@ const FileBrowser = {
|
|||||||
|
|
||||||
this.closeRenameModal();
|
this.closeRenameModal();
|
||||||
this.showGalleryToast('File renamed', 'success');
|
this.showGalleryToast('File renamed', 'success');
|
||||||
|
|
||||||
// Refresh the file list in the background
|
|
||||||
this.loadDirectory(this.currentPath);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error renaming file:', error);
|
console.error('Error renaming file:', error);
|
||||||
errorEl.textContent = error.message;
|
errorEl.textContent = error.message;
|
||||||
|
|||||||
Reference in New Issue
Block a user