修复详情预览切换卡旧图:改用缩略图并按 media.id 重建预览

This commit is contained in:
gallery
2026-11-15 22:08:23 +08:00
parent c5e576caa1
commit 12d142db9d
@@ -166,8 +166,10 @@ const SidebarContent = ({ media, hidePreview }: SidebarContentProps) => {
const { updateSidebar } = useContext(SidebarContext)
const { t } = useTranslation()
let previewImage = null
if (media.highRes) previewImage = media.highRes
else if (media.thumbnail) previewImage = media.thumbnail
// Use the (much smaller) thumbnail for the sidebar preview so switching
// photos is instant instead of waiting for the huge high-res original.
if (media.thumbnail) previewImage = media.thumbnail
else if (media.highRes) previewImage = media.highRes
const imageAspect =
previewImage?.width && previewImage?.height
@@ -219,6 +221,7 @@ const SidebarContent = ({ media, hidePreview }: SidebarContentProps) => {
style={{ paddingTop: `${Math.min(imageAspect, 0.75) * 100}%` }}
>
<PreviewMedia
key={media.id}
previewImage={previewImage || undefined}
media={media}
/>