File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -53,10 +53,27 @@ export const StructurePreviewCard: React.FC<StructurePreviewCardProps> = ({ stru
5353
5454 const rcsbId = structure . name . match ( / ^ [ 1 - 9 ] [ A - Z 0 - 9 ] { 3 } $ / i) ?. [ 0 ] ?. toUpperCase ( ) ;
5555
56- const handleOpen = ( e : React . MouseEvent ) => {
56+ const handleOpen = async ( e : React . MouseEvent ) => {
5757 e . preventDefault ( ) ;
5858 e . stopPropagation ( ) ;
59- navigate ( `/view/${ structure . id } ` ) ;
59+
60+ try {
61+ setLoading ( true ) ;
62+ const { getDownloadUrl } = await import ( '../../lib/structuresService' ) ;
63+ const url = await getDownloadUrl ( structure . file_path ) ;
64+
65+ sessionStorage . setItem ( 'pendingStructure' , JSON . stringify ( {
66+ url,
67+ name : structure . name ,
68+ fileType : structure . file_type . toLowerCase ( )
69+ } ) ) ;
70+
71+ navigate ( '/' ) ;
72+ } catch ( err ) {
73+ console . error ( 'Failed to open structure in viewer:' , err ) ;
74+ } finally {
75+ setLoading ( false ) ;
76+ }
6077 } ;
6178
6279 return (
You can’t perform that action at this time.
0 commit comments