Skip to content

Commit

Permalink
fix: file viewer refreshes when interacting (#2276)
Browse files Browse the repository at this point in the history
  • Loading branch information
MattWong-ca authored Oct 16, 2024
1 parent 6e6bf7e commit 32ef5a2
Showing 1 changed file with 10 additions and 7 deletions.
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

0 comments on commit 32ef5a2

Please sign in to comment.