aboutsummaryrefslogtreecommitdiff
path: root/src/client/util/reportManager/ReportManagerComponents.tsx
diff options
context:
space:
mode:
authorSophie Zhang <sophie_zhang@brown.edu>2023-07-17 22:09:00 -0400
committerSophie Zhang <sophie_zhang@brown.edu>2023-07-17 22:09:00 -0400
commitd561f7d0803205ffded9e374be60853fa90438bd (patch)
tree11ec288499f3beda48b153490ed2f0e72c9f89f0 /src/client/util/reportManager/ReportManagerComponents.tsx
parentc1df53a7616ccbb9afad2deaf3026e70f3e974b4 (diff)
starting component integration
Diffstat (limited to 'src/client/util/reportManager/ReportManagerComponents.tsx')
-rw-r--r--src/client/util/reportManager/ReportManagerComponents.tsx19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/client/util/reportManager/ReportManagerComponents.tsx b/src/client/util/reportManager/ReportManagerComponents.tsx
index 21c0cb43c..576c3c3a1 100644
--- a/src/client/util/reportManager/ReportManagerComponents.tsx
+++ b/src/client/util/reportManager/ReportManagerComponents.tsx
@@ -135,33 +135,43 @@ export const IssueView = ({ issue }: IssueViewProps) => {
};
// Loads an image and returns a promise that resolves as whether the image is valid or not
- const isImgValid = (src: string) => {
- const imgElement = document.createElement('video');
+ const isImgValid = (src: string): Promise<boolean> => {
+ const imgElement = document.createElement('img');
const validPromise: Promise<boolean> = new Promise(resolve => {
imgElement.addEventListener('load', () => resolve(true));
imgElement.addEventListener('error', () => resolve(false));
+ // if taking too long to load, return prematurely (when the browndash server is down)
+ // setTimeout(() => {
+ // resolve(false);
+ // }, 1500);
});
imgElement.src = src;
return validPromise;
};
// Loads a video and returns a promise that resolves as whether the video is valid or not
- const isVideoValid = (src: string) => {
+ const isVideoValid = (src: string): Promise<boolean> => {
const videoElement = document.createElement('video');
const validPromise: Promise<boolean> = new Promise(resolve => {
videoElement.addEventListener('loadeddata', () => resolve(true));
videoElement.addEventListener('error', () => resolve(false));
+ // setTimeout(() => {
+ // resolve(false);
+ // }, 1500);
});
videoElement.src = src;
return validPromise;
};
// Loads audio and returns a promise that resolves as whether the audio is valid or not
- const isAudioValid = (src: string) => {
+ const isAudioValid = (src: string): Promise<boolean> => {
const audioElement = document.createElement('audio');
const validPromise: Promise<boolean> = new Promise(resolve => {
audioElement.addEventListener('loadeddata', () => resolve(true));
audioElement.addEventListener('error', () => resolve(false));
+ // setTimeout(() => {
+ // resolve(false);
+ // }, 1500);
});
audioElement.src = src;
return validPromise;
@@ -169,6 +179,7 @@ export const IssueView = ({ issue }: IssueViewProps) => {
// Called on mount to parse the body
React.useEffect(() => {
+ setIssueBody('Loading...');
parseBody((issue.body as string) ?? '');
}, [issue]);