Skip to content

fix: keep the Save icon hidden on already-saved text notes after swiping#381

Open
MiMoHo wants to merge 1 commit into
FossifyOrg:mainfrom
MiMoHo:fix/issue-210
Open

fix: keep the Save icon hidden on already-saved text notes after swiping#381
MiMoHo wants to merge 1 commit into
FossifyOrg:mainfrom
MiMoHo:fix/issue-210

Conversation

@MiMoHo

@MiMoHo MiMoHo commented Jul 3, 2026

Copy link
Copy Markdown

Type of change(s)

  • Bug fix

What changed and why

With autosave turned off, tapping Save on a text note hid the Save icon correctly, but swiping to another note and back made the icon reappear on a note that had no unsaved changes.

Root cause: Save-icon visibility is computed in MainActivity.currentNoteTextChanged() as showSaveButton = newText != mCurrentNote.value, which is re-run on every swipe-back via TextFragment.setMenuVisibility(true). saveCurrentNote() refreshed mCurrentNote.value only for TYPE_CHECKLIST notes; for TYPE_TEXT notes it left the stale pre-save value in place. Because mCurrentNote is the same object reference as mNotes[currentItem], the stale value survived the page change, so the recomputed comparison savedText != stalePreSaveValue evaluated to true and the Save icon came back.

Fix: add the symmetric else branch to saveCurrentNote() so the in-memory value of a text note is refreshed from the current EditText content right after a save (mCurrentNote.value = getCurrentNoteText() ?: mCurrentNote.value). This mirrors the existing checklist handling and keeps mCurrentNote.value in sync with what was persisted, so the swipe-back recomputation correctly yields false. The ?: mCurrentNote.value fallback preserves the old value if the fragment view is unavailable.

Tests performed

Built the fossDebug variant and verified on an Android 15 (API 35) emulator:

Autosave OFF; created 2 text notes; typed in Note A (Save icon appeared), tapped Save (icon hid), swiped to Note B and back to Note A - Save icon stayed hidden (fix); typed a char - Save icon reappeared (dirty detection intact).

Also confirmed detekt, lint, unit tests and the build all pass locally (CI-equivalent).

Closes the following issue(s)

Checklist

  • I read the contribution guidelines.
  • I manually tested my changes on device/emulator.
  • I updated the "Unreleased" section in CHANGELOG.md (if applicable).
  • I have self-reviewed my pull request (no typos, formatting errors, etc.).
  • I understand every change in this pull request.

Coded with Opus 4.8 ultracode.

When autosave is off, saveCurrentNote() updated mCurrentNote.value only for checklists, leaving the stale pre-save text for TYPE_TEXT notes. Since mCurrentNote is the same object reference as mNotes[currentItem], swiping away and back triggered setMenuVisibility -> currentNoteTextChanged, which recomputed showSaveButton from the stale value and made the Save icon reappear on an already-saved note.

Add the symmetric else branch so the text note's value is refreshed from the current EditText content after a save, keeping it in sync so the swipe-back recomputation correctly yields false.

Fixes FossifyOrg#210
@MiMoHo MiMoHo requested a review from naveensingh as a code owner July 3, 2026 21:29
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.

the 'Save' icon indication bug

1 participant