Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/save note popup appears unmodified #232

Conversation

malachieborohoul
Copy link
Contributor

@malachieborohoul malachieborohoul commented Oct 7, 2024

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

This pull request addresses the issue of unsaved changes detection in the note-taking application. The current implementation of the NotesBloc does not adequately track changes made in the rich text editor when the title, createdAt, allNoteAssets, or tags remain unchanged. This results in situations where the user may unknowingly navigate away from the note without receiving a prompt to save changes.

Solution

When the user clicks the back button in note_create_page.dart or note_read_only_page.dart, the note is retrieved from the database, and its hash is compared to the current hash. If the hashes are different, indicating that the note content has changed, a confirmation popup is displayed to the user; otherwise, the screen is popped without interruption.

This change modularizes the hash comparison logic, allowing for reuse in multiple pages (notes_create_page.dart and note_read_only_page.dart) through the handleWillPop method in the newly created NoteHelper class.

Featured Covered in this PR

  • Implemented hash comparison for detecting unsaved changes in notes.
  • Modularized logic for reuse across different pages.

Related Tickets & Documents

Screenshots, Recordings

diaryvault.online-video-cutter.com.mp4

Tested Feature??

  • In Real Device.
  • In Emulator

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 Thank you for your contribution! Your pull request has been submitted successfully. A maintainer will review it as soon as possible. We appreciate your support in making this project better

@SankethBK
Copy link
Owner

Hi, your approach is correct. I slightly refactored your code by extracting common functions into a mixin to keep it more maintainable. Thanks for contributing!

@SankethBK SankethBK merged commit 22a0770 into SankethBK:master Oct 7, 2024
2 of 3 checks passed
@malachieborohoul
Copy link
Contributor Author

Thank you for the feedback! I’m happy to see my code being improved. I’ll definitely keep the mixin approach in mind.

SankethBK added a commit that referenced this pull request Oct 11, 2024
* Fix Unsaved Changes Detection in Notes: Implement Hash Comparison Logic

* Fix Unsaved Changes Detection in Notes: Implement Hash Comparison Logic

* refactor common methods with mixin

* fix formatting

---------

Co-authored-by: Sanketh B K <[email protected]>
Co-authored-by: Sanketh B K <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Save Note Popup displays even when none of the note content is modified
2 participants