Skip to content

Commit 28e2825

Browse files
refactor: clean up comments in SetupGuide and Tasks components
1 parent 312d413 commit 28e2825

File tree

3 files changed

+8
-21
lines changed

3 files changed

+8
-21
lines changed

frontend/src/components/HomeComponents/SetupGuide/SetupGuide.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Button } from '@/components/ui/button';
66

77
export const SetupGuide = (props: Props) => {
88
const downloadConfigFile = () => {
9-
const configContent = exportConfigSetup(props); // already a string
9+
const configContent = exportConfigSetup(props);
1010
const blob = new Blob([configContent], {
1111
type: 'text/plain;charset=utf-8',
1212
});

frontend/src/components/HomeComponents/Tasks/Tasks.tsx

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,13 @@ export const Tasks = (
139139
const isOverdue = (due?: string) => {
140140
if (!due) return false;
141141

142-
// Taskwarrior format: 20251115T183000Z
143142
const parsed = new Date(
144143
due.replace(
145144
/^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})Z$/,
146145
'$1-$2-$3T$4:$5:$6Z'
147146
)
148147
);
149148

150-
// Convert to local date (ignore time)
151149
const dueDate = new Date(parsed);
152150
dueDate.setHours(0, 0, 0, 0);
153151

@@ -157,7 +155,6 @@ export const Tasks = (
157155
return dueDate < today;
158156
};
159157

160-
// Debounced search handler
161158
const debouncedSearch = debounce((value: string) => {
162159
setDebouncedTerm(value);
163160
setCurrentPage(1);
@@ -198,7 +195,6 @@ export const Tasks = (
198195
}
199196
}, [_selectedTask]);
200197

201-
// Load last sync time from localStorage on mount
202198
useEffect(() => {
203199
const hashedKey = hashKey('lastSyncTime', props.email);
204200
const storedLastSyncTime = localStorage.getItem(hashedKey);
@@ -210,10 +206,8 @@ export const Tasks = (
210206
// Update the displayed time every 10 seconds
211207
useEffect(() => {
212208
const interval = setInterval(() => {
213-
// Force re-render by updating the state
214209
setLastSyncTime((prevTime) => prevTime);
215-
}, 10000); // Update every 10 seconds
216-
210+
}, 10000);
217211
return () => clearInterval(interval);
218212
}, []);
219213

@@ -380,7 +374,6 @@ export const Tasks = (
380374
const newOrder = sortOrder === 'asc' ? 'desc' : 'asc';
381375
setSortOrder(newOrder);
382376
const sorted = sortTasks([...tasks], newOrder);
383-
// Keep both states in sync so the table (which renders from tempTasks) reflects the new order
384377
setTasks(sorted);
385378
setTempTasks(sorted);
386379
setCurrentPage(1);
@@ -618,7 +611,6 @@ export const Tasks = (
618611
});
619612
};
620613

621-
// Master filter
622614
useEffect(() => {
623615
let filteredTasks = [...tasks];
624616

@@ -659,7 +651,6 @@ export const Tasks = (
659651
filteredTasks = results.map((r) => r.item);
660652
}
661653

662-
// Keep overdue tasks always on top
663654
filteredTasks = sortWithOverdueOnTop(filteredTasks);
664655
setTempTasks(filteredTasks);
665656
}, [selectedProjects, selectedTags, selectedStatuses, tasks, debouncedTerm]);
@@ -670,13 +661,12 @@ export const Tasks = (
670661
};
671662

672663
const handleSaveTags = (task: Task) => {
673-
const currentTags = task.tags || []; // Default to an empty array if tags are null
664+
const currentTags = task.tags || [];
674665
const removedTags = currentTags.filter((tag) => !editedTags.includes(tag));
675-
const updatedTags = editedTags.filter((tag) => tag.trim() !== ''); // Remove any empty tags
676-
const tagsToRemove = removedTags.map((tag) => `-${tag}`); // Prefix `-` for removed tags
677-
const finalTags = [...updatedTags, ...tagsToRemove]; // Combine updated and removed tags
666+
const updatedTags = editedTags.filter((tag) => tag.trim() !== '');
667+
const tagsToRemove = removedTags.map((tag) => `-${tag}`);
668+
const finalTags = [...updatedTags, ...tagsToRemove];
678669
console.log(finalTags);
679-
// Call the backend function with updated tags
680670
handleEditTaskOnBackend(
681671
props.email,
682672
props.encryptionSecret,
@@ -692,23 +682,21 @@ export const Tasks = (
692682
task.depends || []
693683
);
694684

695-
setIsEditingTags(false); // Exit editing mode
696-
setEditTagInput(''); // Reset edit tag input
685+
setIsEditingTags(false);
686+
setEditTagInput('');
697687
};
698688

699689
const handleCancelTags = () => {
700690
setIsEditingTags(false);
701691
setEditedTags([]);
702692
};
703693
const handleEditPriorityClick = (task: Task) => {
704-
// Convert empty priority to "NONE" for the select component
705694
setEditedPriority(task.priority || 'NONE');
706695
setIsEditingPriority(true);
707696
};
708697

709698
const handleSavePriority = async (task: Task) => {
710699
try {
711-
// Convert "NONE" to empty string for backend
712700
const priorityValue = editedPriority === 'NONE' ? '' : editedPriority;
713701

714702
await modifyTaskOnBackend({

frontend/src/components/HomePage.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ export const HomePage: React.FC = () => {
133133
});
134134
}
135135
} catch (error) {
136-
// else if (data.status === 'success') {
137136
console.error('Failed to parse message data:', error);
138137
}
139138
};

0 commit comments

Comments
 (0)