-
Notifications
You must be signed in to change notification settings - Fork 3
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
Testnets #142
Testnets #142
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -12,6 +12,12 @@ import { IS_IOS } from "utils/media"; | |||||||||||||
import { useAccount } from "wagmi"; | ||||||||||||||
import { MediaState } from "./Form"; | ||||||||||||||
|
||||||||||||||
const ALLOWED_VIDEO_TYPES = [ | ||||||||||||||
"video/webm", | ||||||||||||||
"video/mp4", | ||||||||||||||
"video/avi", | ||||||||||||||
"video/mov", | ||||||||||||||
]; | ||||||||||||||
const MIN_DIMS = { width: 352, height: 352 }; // PXs | ||||||||||||||
//const MAX_DURATION = 20; // Seconds | ||||||||||||||
//const MAX_SIZE = 7; // Megabytes | ||||||||||||||
|
@@ -22,6 +28,8 @@ const ERROR_MSG = { | |||||||||||||
duration: `Video is too long. Maximum allowed duration is ${MAX_DURATION} seconds long`, | ||||||||||||||
dimensions: `Video dimensions are too small. Minimum dimensions are ${MIN_DIMS.width}px by ${MIN_DIMS.height}px`, | ||||||||||||||
size: `Video is oversized. Maximum allowed size is ${MAX_SIZE}mb`, | ||||||||||||||
fileType: `Unsupported video format. Please use ${ALLOWED_VIDEO_TYPES.map((t) => t.split("/")[1]).join(", ")}`, | ||||||||||||||
unexpected: "Unexpected error. Check format/codecs used.", | ||||||||||||||
}; | ||||||||||||||
interface PhotoProps { | ||||||||||||||
advance: () => void; | ||||||||||||||
|
@@ -142,6 +150,14 @@ function VideoStep({ advance, video$, isRenewal, videoError }: PhotoProps) { | |||||||||||||
onDrop={async (received) => { | ||||||||||||||
try { | ||||||||||||||
const file = received[0]; | ||||||||||||||
if (!ALLOWED_VIDEO_TYPES.includes(file.type)) { | ||||||||||||||
const msg = | ||||||||||||||
"Uploaded file type: " + | ||||||||||||||
file.type.split("/")[1] + | ||||||||||||||
". ".concat(ERROR_MSG.fileType); | ||||||||||||||
videoError(msg); | ||||||||||||||
return console.error(msg); | ||||||||||||||
} | ||||||||||||||
const blob = new Blob([file], { type: file.type }); | ||||||||||||||
const uri = URL.createObjectURL(blob); | ||||||||||||||
|
||||||||||||||
|
@@ -165,7 +181,7 @@ function VideoStep({ advance, video$, isRenewal, videoError }: PhotoProps) { | |||||||||||||
video$.set({ uri, content: blob }); | ||||||||||||||
}); | ||||||||||||||
} catch (error: any) { | ||||||||||||||
videoError("Unexpected error. Check format/codecs used."); | ||||||||||||||
videoError(ERROR_MSG.unexpected); | ||||||||||||||
return console.error(error); | ||||||||||||||
} | ||||||||||||||
Comment on lines
+184
to
186
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Improve error handling and debugging. While using a generic error message for users is good, we should preserve error details for debugging: - videoError(ERROR_MSG.unexpected);
- return console.error(error);
+ videoError(ERROR_MSG.unexpected);
+ return console.error('Video processing failed:', error); Consider adding error tracking/monitoring for production environments to help identify and fix issues proactively. 📝 Committable suggestion
Suggested change
|
||||||||||||||
}} | ||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Enhance file type validation robustness.
The current validation logic could be improved for better maintainability and reliability:
This change:
📝 Committable suggestion