Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: PDF viewer refreshes when interacting with web UI #2276

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions src/files/FilesPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ const FilesPage = ({
}

const MainView = ({ t, files, remotePins, pendingPins, failedPins, doExploreUserProvidedPath }) => {
if (!files) return (<div/>)
if (!files || files.type === 'file') return (<div/>)

if (files.type === 'unknown') {
const path = files.path
Expand All @@ -130,12 +130,6 @@ const FilesPage = ({
)
}

if (files.type === 'file') {
return (
<FilePreview {...files} onDownload={() => onDownload([files])} />
)
}

return (
<FilesList
key={window.encodeURIComponent(files.path)}
Expand Down Expand Up @@ -216,6 +210,8 @@ const FilesPage = ({

<MainView t={t} files={files} remotePins={remotePins} pendingPins={pendingPins} failedPins={failedPins} doExploreUserProvidedPath={doExploreUserProvidedPath}/>

<Preview files={files} onDownload={() => onDownload([files])} />

<InfoBoxes isRoot={filesPathInfo.isMfs && filesPathInfo.isRoot}
isCompanion={false}
filesExist={!!(files && files.content && files.content.length)} />
Expand Down Expand Up @@ -248,6 +244,13 @@ const FilesPage = ({
)
}

const Preview = ({ files, onDownload }) => {
if (files && files.type === 'file') {
return (<FilePreview {...files} onDownload={onDownload} />)
}
return (<div/>)
}

export default connect(
'selectIpfsProvider',
'selectIpfsConnected',
Expand Down
Loading