Skip to content

Commit 846f026

Browse files
committed
Fix tab switching not allowing task start
1 parent 2e17128 commit 846f026

File tree

7 files changed

+17
-14
lines changed

7 files changed

+17
-14
lines changed

back/src/routers/taskRouter.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@ interface NewUserInfo {
1818

1919
const checkIfTimeSurpassed = async (startTime: number, task: TaskInterface) => {
2020
const time = getCurrentEpochInSeconds();
21-
console.log(((time - startTime) / 1000), task.timeLeftToday);
2221
if (startTime !== -1 && task.timeLeftToday !== 0 && (((time - startTime) / 1000) >= task.timeLeftToday)) {
2322
task.totalTimeToday += task.timeLeftToday;
2423
task.timeLeftToday = 0;
25-
console.log('obama');
2624
await task.save();
2725
return true;
2826
}

back/src/utils/socketConnection.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ const getTaskIdsFromUser = (user: UserInterface): string[] => {
1313

1414
export const handleSocket = (io: Server): void => {
1515
io.on('connection', (socket) => {
16-
console.log('WebSocket connected');
1716
// Socket connection initiated by listening to changes in specific user
1817
socket.on('subscribeToUser', async (userId) => {
1918
try {
@@ -22,9 +21,7 @@ export const handleSocket = (io: Server): void => {
2221
console.log('User not found');
2322
return;
2423
}
25-
console.log('Subscribing to user:', user.username);
2624
let ids = getTaskIdsFromUser(user);
27-
console.log(ids);
2825
const taskChangeStream = Task.collection.watch();
2926
const userChangeStream = User.collection.watch();
3027
// Emit changes in Task document
@@ -42,7 +39,6 @@ export const handleSocket = (io: Server): void => {
4239
}
4340
});
4441
socket.on('disconnect', () => {
45-
console.log('WebSocket disconnected');
4642
taskChangeStream.close();
4743
userChangeStream.close();
4844
});

front/taskwizard-front/src/components/NewTask.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ const NewTask = ({ isOpen, onClose }: { isOpen: boolean, onClose: () => void}) =
371371
isClosable: true
372372
});
373373
} else {
374-
console.log('poop');
374+
console.log('New task created');
375375
}
376376
};
377377
return (

front/taskwizard-front/src/components/StartableTask.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,18 @@ import { setStart } from '../redux/dashboardSlice';
1212
const StartableTask = ({ task }: { task: TaskInterface }) => {
1313
const [screenCutoff] = useMediaQuery('(min-width: 600px)');
1414
const [countAmount, setCountAmount] = useState(1);
15-
const [started, setStarted] = useState(false);
15+
const [started, _setStarted] = useState(false);
1616
const [overtime, setOvertime] = useState(false);
1717
const [timeLeft, setTimeLeft] = useState(task.timeLeftToday);
1818
const [totalTime, setTotalTime] = useState(task.totalTimeToday);
1919
const { isOpen, onOpen, onClose } = useDisclosure();
2020
const cancelRef = useRef(null);
2121
const toast = useToast();
2222
const startedRef = useRef(started);
23+
const setStarted = (data: boolean) => {
24+
startedRef.current = data;
25+
_setStarted(data);
26+
};
2327
const handleCountChange = (amount: string) => {
2428
const amountNum = parseInt(amount);
2529
setCountAmount(amountNum);
@@ -66,10 +70,11 @@ const StartableTask = ({ task }: { task: TaskInterface }) => {
6670
useEffect(() => {
6771
const handleVisibilityChange = async () => {
6872
if (!document.hidden) {
73+
console.log(startedRef.current);
6974
await stopTask(task.id);
7075
if (task.timeLeftToday <= 1) {
71-
handleStartedStateChange(setStarted, false);
72-
} else if (startedRef) {
76+
handleStartedStateChange(_setStarted, false);
77+
} else if (startedRef.current) {
7378
await startTask(task.id);
7479
}
7580
}

front/taskwizard-front/src/pages/Info.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, { useEffect, useState } from 'react';
22
import '../index.css';
33
import { Image, Flex, Button, Heading, Box, useMediaQuery } from '@chakra-ui/react';
44
import NavBar1 from '../components/NavBar1';
5+
import NavBar2 from '../components/NavBar2';
56
import SignupButton from '../components/SignupButton';
67
import { checkToken } from '../utils/checkToken';
78
import { useNavigate } from 'react-router-dom';
@@ -10,12 +11,16 @@ const Info = () => {
1011
const [screenCutoff] = useMediaQuery('(min-width: 600px)');
1112
return (
1213
<>
13-
<NavBar1/>
14+
{
15+
window.localStorage.getItem('logged') === 'true'
16+
? <NavBar2/>
17+
: <NavBar1/>
18+
}
1419
<Flex overflow='auto' justifyContent={screenCutoff ? 'center' : ''} alignItems='center' direction='column' height = 'calc(85vh - 50px)'>
1520
<Heading size='md'>About TaskWizard</Heading>
1621
<Box textAlign='center' w='50%'> TaskWizard is a project I made independtly over the course of a month or so as I found other ways of managing my time inconvenient and inefficient. I also wanted to make time management social and shareable with TaskWizard's friend adding fuctionality. TaskWizard utilizes React on the frontend and Node/Express/MongoDB for the backend, all of which utilizes TypeScript.</Box>
1722
<Heading size='md' mt = '8'>About Me</Heading>
18-
<Box textAlign='center' w='50%'>I am currently a student studying computer science in college. I am very interesting in software development, especially web development. I've always enjoyed being creative while also having a quantitative mindset, which is what drew me to programming.</Box>
23+
<Box textAlign='center' w='50%'>I am currently a student studying computer science in college. I am very interested in software development, especially web development.</Box>
1924
<Heading size='md' mt = '8'>How to Use TaskWizard?</Heading>
2025
<Box textAlign='center' w='50%'>The awesome thing about TaskWizard is that not only is it effective, it is very easy to use. Everything should be explained in the 'TaskWizard: At a Glance' video. You can view it here.</Box>
2126
<Heading size='md' mt = '8'>How to Use Contribute?</Heading>

front/taskwizard-front/src/pages/Login.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ function Login () {
8484
async function requestStorage () {
8585
try {
8686
await document.requestStorageAccess();
87-
console.log(await document.hasStorageAccess());
8887
} catch (error) {
8988
// Handle errors, e.g., if the browser doesn't support this API.
9089
console.error('Error requesting storage access:', error);

front/taskwizard-front/src/pages/Signup.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ function Signup () {
125125
<>
126126
{isNotLoaded && <Loader/>}
127127
<NavBar1/>
128-
<Flex overflow='auto' onLoad = {handleLoad} alignItems='center' justifyContent='center' direction={screenCutoff ? 'row-reverse' : 'column'} height = {screenCutoff ? 'calc(82vh - 95px)' : 'calc(70vh - 95px)'} gap = '30px'>
128+
<Flex overflow='auto' onLoad = {handleLoad} alignItems='center' justifyContent='center' direction={screenCutoff ? 'row-reverse' : 'column'} height = {screenCutoff ? 'calc(82vh - 95px)' : 'calc(75vh - 95px)'} gap = '30px'>
129129
<Image
130130
src= 'https://cdn-icons-png.flaticon.com/512/477/477103.png'
131131
height={!screenCutoff ? 'clamp(50px, 20%, 300px)' : 'clamp(100px, 40%, 300px)'}

0 commit comments

Comments
 (0)