@@ -436,8 +436,8 @@ function ImagePreview({ file }: { file: WorkspaceFileRecord }) {
436436
437437const pptxSlideCache = new Map < string , string [ ] > ( )
438438
439- function pptxCacheKey ( fileId : string , dataUpdatedAt : number ) : string {
440- return `${ fileId } :${ dataUpdatedAt } `
439+ function pptxCacheKey ( fileId : string , byteLength : number ) : string {
440+ return `${ fileId } :${ byteLength } `
441441}
442442
443443function pptxCacheSet ( key : string , slides : string [ ] ) : void {
@@ -492,11 +492,15 @@ async function getPptxRenderSize(
492492 const presentationXml = await zip . file ( 'ppt/presentation.xml' ) ?. async ( 'text' )
493493 if ( ! presentationXml ) return fallback
494494
495- const match = presentationXml . match ( / < p : s l d S z [ ^ > ] * c x = " ( \d + ) " [ ^ > ] * c y = " ( \d + ) " / )
496- if ( ! match ) return fallback
495+ const tagMatch = presentationXml . match ( / < p : s l d S z \s [ ^ > ] + > / )
496+ if ( ! tagMatch ) return fallback
497+ const tag = tagMatch [ 0 ]
498+ const cxMatch = tag . match ( / \b c x = " ( \d + ) " / )
499+ const cyMatch = tag . match ( / \b c y = " ( \d + ) " / )
500+ if ( ! cxMatch || ! cyMatch ) return fallback
497501
498- const cx = Number ( match [ 1 ] )
499- const cy = Number ( match [ 2 ] )
502+ const cx = Number ( cxMatch [ 1 ] )
503+ const cy = Number ( cyMatch [ 1 ] )
500504 if ( ! Number . isFinite ( cx ) || ! Number . isFinite ( cy ) || cx <= 0 || cy <= 0 ) return fallback
501505
502506 const aspectRatio = cx / cy
@@ -532,10 +536,9 @@ function PptxPreview({
532536 data : fileData ,
533537 isLoading : isFetching ,
534538 error : fetchError ,
535- dataUpdatedAt,
536539 } = useWorkspaceFileBinary ( workspaceId , file . id , file . key )
537540
538- const cacheKey = pptxCacheKey ( file . id , dataUpdatedAt )
541+ const cacheKey = pptxCacheKey ( file . id , fileData ?. byteLength ?? 0 )
539542 const cached = pptxSlideCache . get ( cacheKey )
540543
541544 const [ slides , setSlides ] = useState < string [ ] > ( cached ?? [ ] )
0 commit comments