Skip to content

Commit

Permalink
Hotfix: Video support for private files (#1128)
Browse files Browse the repository at this point in the history
* hotfix: Fix type mismatch in the VideoDisplay

* refactor: Remove console.log
  • Loading branch information
PintoGideon authored Mar 27, 2024
1 parent 4696d3b commit f9a5fc7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/components/Preview/FileDetailView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ const FileDetailView = (props: AllProps) => {
blob,
file: selectedFile,
fileType,
url: "",
};
} catch (error: any) {
setError("Failed to fetch the data for preview");
Expand Down
20 changes: 12 additions & 8 deletions src/components/Preview/displays/IframeDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,19 @@ const IframeDisplay: React.FunctionComponent<AllProps> = (props: AllProps) => {
let url = "";

if (fileItem.fileType === "html") {
url = fileItem.blob
? window.URL.createObjectURL(
new Blob([fileItem.blob], { type: "text/html" }),
)
: "";
url = fileItem.url
? fileItem.url
: fileItem.blob
? window.URL.createObjectURL(
new Blob([fileItem.blob], { type: "text/html" }),
)
: "";
} else {
url = fileItem.blob
? window.URL.createObjectURL(new Blob([fileItem.blob]))
: "";
url = fileItem.url
? fileItem.url
: fileItem.blob
? window.URL.createObjectURL(new Blob([fileItem.blob]))
: "";
}

return (
Expand Down
5 changes: 3 additions & 2 deletions src/components/Preview/displays/VideoDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ const VideoDisplay = (props: AllProps) => {
: blob
? window.URL.createObjectURL(new Blob([blob], { type: blob.type }))
: "";
const sourceType = url ? fileType : blob ? blob.type : "";

const sourceType = url ? `video/${fileType}` : blob ? blob.type : "";

return (
// biome-ignore lint/a11y/useMediaCaption: <explanation>
<video controls width="90%" height="90%">
<source src={urlToFetch} type={`video/${sourceType}`} />
<source src={urlToFetch} type={sourceType} />
{/* Fallback message for browsers that do not support video playback */}
Your browser does not support the video tag.
</video>
Expand Down

0 comments on commit f9a5fc7

Please sign in to comment.