jargons.dev icon indicating copy to clipboard operation
jargons.dev copied to clipboard

Implement content comparison before submitting changes in `word-editor`

Open babblebey opened this issue 10 months ago • 0 comments

Currently, when submitting a new word or editing an existing word, the submission is processed without checking if any actual changes have been made to the content. This can lead to redundant operations and unnecessary updates to the dictionary. To improve efficiency, we should implement a content comparison check before submitting changes. This check should compare the new content with the existing content and only proceed with the submission if there are actual changes.

This enhancement is particularly needed in the edit existing word action; kindly refer to the PR #32 for context of the edit word action.

Related files:

  • handleSubmitWord Handler - https://github.com/babblebey/jargons.dev/blob/main/src/lib/handlers/handle-submit-word.js
  • WordEditor component (island) - https://github.com/babblebey/jargons.dev/blob/main/src/components/islands/word-editor.jsx

Tasks:

  • Modify the concerned point, word-editor island or handleSubmitWord handler to include a content comparison check before submitting changes.
  • If no changes are detected, prevent the submission by disabling the submit button or displaying a message to the user indicating that no changes were made.
  • Ensure that the content comparison is thorough and accounts for all relevant fields and properties of the word.

Additional Information:

  • Consider adding visual indicators to the UI to highlight areas where changes have been made. (this one might be worth a separate issue on its own 😜)
  • Test the content comparison thoroughly to ensure it accurately detects changes and avoids false positives.

babblebey avatar Apr 13 '24 17:04 babblebey