(groupRecord)
| 19467 | |
| 19468 | const selected = Array.from(selectedModels).filter(Boolean); |
| 19469 | const clickedSelected = clickedFilePath && isInSelectedModels(clickedFilePath); |
| 19470 | |
| 19471 | if (selected.length > 1 && clickedSelected) { |
| 19472 | return selected; |
| 19473 | } |
| 19474 | |
| 19475 | // Multi-edit mode with a selection: operate on all selected even if the click |
| 19476 | // target path format differs slightly from the Set entry. |
| 19477 | if (isMultiSelectMode && selected.length > 1) { |
| 19478 | return selected; |
| 19479 | } |
| 19480 | |
| 19481 | if (clickedFilePath) return [clickedFilePath]; |
| 19482 | return selected.length ? selected : []; |
| 19483 | } |
| 19484 | |
| 19485 | function addThumbnailMenuButton(thumbnailContainer, filePath) { |
| 19486 | if (!thumbnailContainer || !filePath) return; |
| 19487 | if (thumbnailContainer.querySelector('.thumbnail-menu-button')) return; |
| 19488 | |
| 19489 | const button = document.createElement('button'); |
| 19490 | button.type = 'button'; |
| 19491 | button.className = 'thumbnail-menu-button'; |
| 19492 | button.textContent = '...'; |
| 19493 | button.title = 'Menu'; |
| 19494 | button.addEventListener('click', async (e) => { |
| 19495 | e.preventDefault(); |
| 19496 | e.stopPropagation(); |
| 19497 | |
| 19498 | const rect = button.getBoundingClientRect(); |
| 19499 | const x = rect.left; |
| 19500 | const y = rect.bottom; |
| 19501 | |
| 19502 | try { |
| 19503 | const paths = resolveContextMenuFilePaths(filePath); |
| 19504 | const menuResult = paths.length > 1 |
| 19505 | ? await window.electron.showContextMenu(paths) |
| 19506 | : await window.electron.showContextMenu(paths[0] || filePath); |
| 19507 | |
| 19508 | if (menuResult && menuResult.type === 'html-menu') { |
| 19509 | showHtmlContextMenu(menuResult, x, y, { showClose: true }); |
| 19510 | } |
| 19511 | } catch (error) { |
| 19512 | console.error('Error showing context menu:', error); |
| 19513 | } |
| 19514 | }); |
| 19515 | |
| 19516 | thumbnailContainer.appendChild(button); |
| 19517 | } |
| 19518 | |
| 19519 | // Add this function near other file rendering functions |
| 19520 | function suppressTileTap(fileElement, ms = 600) { |
| 19521 | if (!fileElement) return; |
| 19522 | fileElement._suppressTap = true; |
| 19523 | clearTimeout(fileElement._suppressTapTimer); |
| 19524 | fileElement._suppressTapTimer = setTimeout(() => { |
| 19525 | fileElement._suppressTap = false; |
| 19526 | }, ms); |
no test coverage detected