react-scan icon indicating copy to clipboard operation
react-scan copied to clipboard

fix: add unique identifiers to tasks for accurate deletion

Open pradeepkaswan opened this issue 1 year ago • 3 comments

Summary

This pull request addresses an issue where tasks with the same text could not be accurately deleted due to the lack of unique identifiers. By assigning a unique id to each task, we ensure that tasks can be correctly identified and managed.

Changes Made

  • AddTaskBar Component: Modified to assign a unique id to each task using Date.now().
  • TaskList and TaskItem Components: Updated to handle tasks with unique ids, ensuring accurate deletion.
  • State Management: Updated the tasks state to be an array of objects, each containing an id and text.

Why This Change?

Previously, tasks were identified by their text value, leading to conflicts when tasks with the same text were added. This change ensures that each task has a unique identifier, allowing for accurate management and deletion of tasks.

How to Test

  1. Add multiple tasks with the same text.
  2. Delete tasks and verify that the correct task is removed.
  3. Ensure that the task list updates correctly after deletion.

Related Issue

Fixes #61

pradeepkaswan avatar Dec 02 '24 06:12 pradeepkaswan

Someone is attempting to deploy a commit to the Million Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Dec 02 '24 06:12 vercel[bot]

Hey @pradeepkaswan :) I just saw Date.now() and If accurate and reliable timing is critical, performance.now() is the better choice 🚀

pivanov avatar Dec 02 '24 21:12 pivanov

Hey @pradeepkaswan :) I just saw Date.now() and If accurate and reliable timing is critical, performance.now() is the better choice 🚀

Thanks for the suggestion, @pivanov ! I have updated the timing function to use performance.now() for better accuracy. The changes have been pushed.

pradeepkaswan avatar Dec 03 '24 06:12 pradeepkaswan