-
Notifications
You must be signed in to change notification settings - Fork 716
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix bug when the app is quit with a pdf opened
- Loading branch information
1 parent
559d711
commit ff7e060
Showing
5 changed files
with
87 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,47 @@ | ||
import { Box, IconButton } from '@rocket.chat/fuselage'; | ||
import { useState, useEffect } from 'react'; | ||
|
||
const DynamicWebview = ({ | ||
const DocumentViewer = ({ | ||
url, | ||
isActive, | ||
partition, | ||
closeDocumentViewer, | ||
}: { | ||
url: string; | ||
isActive: boolean; | ||
partition: string; | ||
closeDocumentViewer: () => void; | ||
}) => { | ||
const [webView, setWebView] = useState<JSX.Element | null>(null); | ||
|
||
useEffect(() => { | ||
if (isActive && url) { | ||
setWebView( | ||
<webview | ||
src={url} | ||
style={{ | ||
width: '100%', | ||
height: '100%', | ||
position: 'absolute', | ||
left: 0, | ||
top: 50, | ||
right: 0, | ||
bottom: 0, | ||
}} | ||
partition={partition} | ||
/> | ||
); | ||
} else { | ||
setWebView(null); | ||
} | ||
}, [url, isActive, partition]); | ||
|
||
return ( | ||
<> | ||
{isActive && ( | ||
<Box | ||
bg='light' | ||
width='100%' | ||
height='100%' | ||
position='absolute' | ||
content='center' | ||
alignItems='center' | ||
> | ||
<Box content='center' alignItems='center' display='flex'> | ||
<IconButton | ||
icon='arrow-back' | ||
onClick={closeDocumentViewer} | ||
mi='x8' | ||
/> | ||
<h2>PDF Viewer</h2> | ||
</Box> | ||
<Box | ||
bg='light' | ||
width='100%' | ||
height='100%' | ||
position='absolute' | ||
content='center' | ||
alignItems='center' | ||
> | ||
<Box content='center' alignItems='center' display='flex'> | ||
<IconButton icon='arrow-back' onClick={closeDocumentViewer} mi='x8' /> | ||
<h2>PDF Viewer</h2> | ||
</Box> | ||
|
||
<Box>{webView}</Box> | ||
<Box> | ||
<webview | ||
src={url} | ||
style={{ | ||
width: '100%', | ||
height: '100%', | ||
position: 'absolute', | ||
left: 0, | ||
top: 50, | ||
right: 0, | ||
bottom: 0, | ||
}} | ||
partition={partition} | ||
/> | ||
</Box> | ||
)} | ||
</Box> | ||
</> | ||
); | ||
}; | ||
|
||
export default DynamicWebview; | ||
export default DocumentViewer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters