Skip to content

Commit

Permalink
Merge pull request #22 from Ritika8081/main
Browse files Browse the repository at this point in the history
desable channel inc/dec button while recording
  • Loading branch information
akadeepesh authored Sep 23, 2024
2 parents 7844a94 + fb531bc commit ff7995f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions src/components/Connection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ const Connection: React.FC<ConnectionProps> = ({
const [isRecordButtonDisabled, setIsRecordButtonDisabled] = useState(false); // New state variable
const [datasets, setDatasets] = useState<string[][][]>([]); // State to store the recorded datasets
const [hasData, setHasData] = useState(false);
const [recData, setrecData] = useState(false);
const [elapsedTime, setElapsedTime] = useState<number>(0); // State to store the recording duration
const timerIntervalRef = useRef<NodeJS.Timeout | null>(null); // Ref to store the timer interval
const [customTime, setCustomTime] = useState<string>(""); // State to store the custom stop time input
Expand Down Expand Up @@ -393,7 +394,7 @@ const Connection: React.FC<ConnectionProps> = ({
startTimeRef.current = nowTime;
setElapsedTime(0);
timerIntervalRef.current = setInterval(checkRecordingTime, 1000);

setrecData(true);
// Initialize IndexedDB for this recording session
try {
const db = await initIndexedDB();
Expand Down Expand Up @@ -464,6 +465,7 @@ const Connection: React.FC<ConnectionProps> = ({
indexedDBRef.current.close();
indexedDBRef.current = null;
}
setrecData(false);

toast.success("Recording completed Successfully", {
description: (
Expand Down Expand Up @@ -830,6 +832,7 @@ const Connection: React.FC<ConnectionProps> = ({
<Button
onClick={handleRecord}
disabled={isRecordButtonDisabled || !isDisplay}

>
{isRecordingRef.current ? (
<CircleStop />
Expand Down Expand Up @@ -935,7 +938,7 @@ const Connection: React.FC<ConnectionProps> = ({
<Button
className="rounded-r-none"
onClick={decreaseCanvas}
disabled={canvasCount === 1 || !isDisplay}
disabled={canvasCount === 1 || !isDisplay || recData}
>
<Minus size={16} />
</Button>
Expand All @@ -957,7 +960,7 @@ const Connection: React.FC<ConnectionProps> = ({
<Button
className="flex items-center justify-center px-3 py-2 m-1 rounded-none select-none"
onClick={toggleShowAllChannels}
disabled={!isDisplay}
disabled={!isDisplay || recData}
>
CH
</Button>
Expand All @@ -979,7 +982,7 @@ const Connection: React.FC<ConnectionProps> = ({
<Button
className="rounded-l-none"
onClick={increaseCanvas}
disabled={canvasCount >= 6 || !isDisplay}
disabled={canvasCount >= 6 || !isDisplay || recData}
>
<Plus size={16} />
</Button>
Expand Down
2 changes: 1 addition & 1 deletion src/components/DataPass.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const DataPass = () => {
const [selectedBits, setSelectedBits] = useState<BitSelection>("auto"); // Selected bits
const [isConnected, setIsConnected] = useState<boolean>(false); // Connection status
const [isDisplay, setIsDisplay] = useState<boolean>(true); // Display state
const [canvasCount, setCanvasCount] = useState<number>(6); // Number of canvases
const [canvasCount, setCanvasCount] = useState<number>(1); // Number of canvases
const [channelCount, setChannelCount] = useState<number>(1); // Number of channels

return (
Expand Down

0 comments on commit ff7995f

Please sign in to comment.