Skip to content

Commit

Permalink
Revert "release: v0.2.3 - recording + muxing improvements, deleting, …
Browse files Browse the repository at this point in the history
…usage"

This reverts commit 3ae38cd.
  • Loading branch information
richiemcilroy committed Apr 30, 2024
1 parent 3ae38cd commit 6ee8ac4
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 16 deletions.
50 changes: 35 additions & 15 deletions apps/desktop/src/components/windows/inner/Recorder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ export const Recorder = () => {
const [currentStoppingMessage, setCurrentStoppingMessage] =
useState("Stopping Recording");
const [recordingTime, setRecordingTime] = useState("00:00");
const [canStopRecording, setCanStopRecording] = useState(false);
const [hasStartedRecording, setHasStartedRecording] = useState(false);
const tauriWindow = import("@tauri-apps/api/window");
const proCheckPromise = isUserPro();
const [proCheck, setProCheck] = useState<boolean>(false);
const [limitReached, setLimitReached] = useState(false);

useEffect(() => {
proCheckPromise.then((result) => setProCheck(Boolean(result)));
Expand Down Expand Up @@ -175,7 +175,7 @@ export const Recorder = () => {
unlistenFn();
}
};
}, [isRecording, canStopRecording]);
}, [isRecording]);

const startDualRecording = async (videoData: {
id: string;
Expand Down Expand Up @@ -248,10 +248,6 @@ export const Recorder = () => {
};

const handleStopAllRecordings = async () => {
if (!canStopRecording) {
toast.error("Recording must be for a minimum of 5 seconds.");
return;
}
setStoppingRecording(true);

try {
Expand Down Expand Up @@ -300,14 +296,12 @@ export const Recorder = () => {
setIsRecording(false);
setHasStartedRecording(false);
setStoppingRecording(false);
setCanStopRecording(false);
await emit("toggle-recording", false);
} catch (error) {
console.error("Error stopping recording:", error);
}

setIsRecording(false);
// setCountdownActive(false);
setStoppingRecording(false);
};

Expand Down Expand Up @@ -337,27 +331,53 @@ export const Recorder = () => {
if (isRecording && !startingRecording) {
const startTime = Date.now();

setTimeout(() => setCanStopRecording(true), 5000);

intervalId = setInterval(() => {
const seconds = Math.floor((Date.now() - startTime) / 1000);
const minutes = Math.floor(seconds / 60);
const formattedSeconds =
seconds % 60 < 10 ? `0${seconds % 60}` : seconds % 60;
setRecordingTime(`${minutes}:${formattedSeconds}`);

if (seconds >= 300) {
handleStopAllRecordings();
}
}, 1000);
}

return () => {
clearInterval(intervalId);
setRecordingTime("00:00");
};
}, [isRecording, startingRecording]);

useEffect(() => {
if (isRecording && !startingRecording && !proCheck && !limitReached) {
const startTime = Date.now();
let intervalId: NodeJS.Timeout;

intervalId = setInterval(() => {
const seconds = Math.floor((Date.now() - startTime) / 1000);
if (seconds >= 300) {
setLimitReached(true);
tauriWindow.then(({ getCurrent }) => {
const currentWindow = getCurrent();
if (currentWindow.isMinimized()) {
currentWindow.unminimize();
toast.error(
"5 minute recording limit reached. Stopping recording in 10 seconds."
);

setTimeout(() => {
handleStopAllRecordings();
return;
}, 10000);
}
});
}
}, 1000);

return () => {
clearInterval(intervalId);
setLimitReached(false);
};
}
}, [isRecording, startingRecording, proCheck, limitReached]);

return (
<>
{/* {countdownActive && (
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/api/desktop/plan/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export async function GET(req: NextRequest) {
}

const isSubscribed = isUserOnProPlan({
subscriptionStatus: user.stripeSubscriptionStatus || "",
subscriptionStatus: user.stripeSubscriptionStatus as string,
});

return new Response(
Expand Down

1 comment on commit 6ee8ac4

@vercel
Copy link

@vercel vercel bot commented on 6ee8ac4 Apr 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.