Skip to content

Commit b22db39

Browse files
committed
Bug fix to work around the eslint
1 parent 33e018f commit b22db39

4 files changed

Lines changed: 10 additions & 24 deletions

File tree

src/components/app-preview-container.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,7 @@ export default function AppPreviewContainer() {
3636
<UploadButtonProvider>
3737
<div className="flex justify-center items-center">
3838
<div className="max-w-3xl w-full mx-auto my-24">
39-
<VideoConvertFlow
40-
onFileSelected={handleFileSelected}
41-
onPlatformSelected={handlePlatformSelected}
42-
onAudioSelected={handleAudioSelected}
43-
onConversionComplete={handleConversionComplete}
44-
/>
39+
<div className="animate-pulse bg-gray-200 h-96 rounded-lg"></div>
4540
</div>
4641
</div>
4742
</UploadButtonProvider>

src/components/video-convert/VideoConvertFlow.tsx

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ export default function VideoConvertFlow({
9494
};
9595
};
9696

97+
// This effect needs to run only when uploadKey changes
98+
// to avoid infinite re-render loops
99+
/* eslint-disable react-hooks/exhaustive-deps */
97100
useEffect(() => {
98101
initializeMessages();
99102
show(); // Show upload button when component mounts
@@ -111,7 +114,8 @@ export default function VideoConvertFlow({
111114
updateMessage(errorMessage, 'error');
112115
}
113116
});
114-
}, [uploadKey, show, hide, initializeMessages, addUploadPrompt, onFileSelected, updateMessage, addPlatformPrompt]);
117+
}, [uploadKey]);
118+
/* eslint-enable react-hooks/exhaustive-deps */
115119

116120
const handlePlatformSelection = (action: string) => {
117121
if (action === 'macos' || action === 'ios') {
@@ -196,22 +200,7 @@ export default function VideoConvertFlow({
196200
setAddSilentAudio(true);
197201
setConvertedVideoUrl(null);
198202
setUploadKey(prev => prev + 1);
199-
show(); // Show upload button on restart
200-
initializeMessages();
201-
addUploadPrompt(async (file: File) => {
202-
const validation = await validateVideo(file);
203-
204-
if (validation.isValid) {
205-
setVideoFile(file);
206-
onFileSelected(file);
207-
updateMessage(`${file.name} uploaded successfully!`, 'success');
208-
hide(); // Hide upload button on success
209-
addPlatformPrompt();
210-
} else {
211-
const errorMessage = validation.errors.join(' and ');
212-
updateMessage(errorMessage, 'error');
213-
}
214-
});
203+
// The rest will be handled by the useEffect when uploadKey changes
215204
};
216205

217206
return (

src/components/video-upload/VideoUploadFlow.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ export default function VideoUploadFlow({ onFileSelected }: VideoUploadFlowProps
1515
addPlatformPrompt
1616
} = useTerminalMessages();
1717

18+
// This effect should only run once on mount
19+
// eslint-disable-next-line react-hooks/exhaustive-deps
1820
useEffect(() => {
1921
initializeMessages();
2022
addUploadPrompt((file: File) => {

src/hooks/useTerminalMessages.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const useTerminalMessages = () => {
99
{ text: "Welcome to App Preview Converter v1.0.0", delay: 0, type: "info" },
1010
{ text: "This tool helps you convert videos for App Store submissions", delay: 2100, type: "info" },
1111
];
12-
setMessages(initialMessages);
12+
setMessages(() => initialMessages);
1313
};
1414

1515
const addUploadPrompt = (onFileUpload: (file: File) => void) => {

0 commit comments

Comments
 (0)