request all thumbnail on separate route instead

This commit is contained in:
spencerwooo
2022-02-10 10:47:58 +08:00
parent dbb5e185da
commit cf97983063
5 changed files with 14 additions and 21 deletions
+2 -11
View File
@@ -12,17 +12,8 @@ import { getReadablePath } from '../utils/getReadablePath'
import { Checkbox, ChildIcon, Downloading, formatChildName } from './FileListing'
const GridItem = ({ c, path }: { c: OdFolderChildren; path: string }) => {
// We use the generated medium thumbnail for rendering preview images
const thumbnailUrl =
'folder' in c
? // Folders don't have thumbnails
null
: c.thumbnails && c.thumbnails.length > 0
? // Most OneDrive versions, including E5 developer, should have thumbnails returned
c.thumbnails[0].medium.url
: // According to OneDrive docs, OneDrive for Business and SharePoint does not
// (can not retrieve thumbnails via expand). But currently we only see OneDrive 世纪互联 really does not.
`/api/thumbnail?path=${path}`
// We use the generated medium thumbnail for rendering preview images (excluding folders)
const thumbnailUrl = 'folder' in c ? null : `/api/thumbnail?path=${path}&size=medium`
// Some thumbnails are broken, so we check for onerror event in the image component
const [brokenThumbnail, setBrokenThumbnail] = useState(false)