Skip to content

Fix note ids in imported notes with note links#798

Merged
Crustack merged 1 commit into
mainfrom
fix/imported-note-links
Jan 25, 2026
Merged

Fix note ids in imported notes with note links#798
Crustack merged 1 commit into
mainfrom
fix/imported-note-links

Conversation

@Crustack
Copy link
Copy Markdown
Owner

@Crustack Crustack commented Jan 25, 2026

Fixes #785

Summary by CodeRabbit

  • Improvements
    • Enhanced backup restoration to properly preserve and update internal note references when importing backup files.
    • Improved database synchronization during backup import to maintain data integrity and link consistency between notes.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 25, 2026

📝 Walkthrough

Walkthrough

This change fixes a backup restore issue by implementing ID remapping for note links. During import, original database IDs are collected, new IDs are generated for imported notes, note:// links within spans are remapped to use new IDs, and affected spans are updated.

Changes

Cohort / File(s) Summary
DAO Layer Updates
app/src/main/java/com/philkes/notallyx/data/dao/BaseNoteDao.kt, app/src/main/java/com/philkes/notallyx/data/dao/CommonDao.kt
BaseNoteDao.insert() now returns List with generated IDs instead of void. New updateSpans() method added to update spans field for a specific note. CommonDao introduces new importBackup() overload that accepts original IDs, performs bulk insertion, creates old-to-new ID mapping, remaps note:// links in spans to new IDs, updates spans via updateSpans(), and inserts labels.
Import Process
app/src/main/java/com/philkes/notallyx/utils/backup/ImportExtensions.kt
Extends import flow to collect original database row IDs from BaseNote cursor and pass them alongside baseNotes and labels to updated importBackup() method signature.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A link was lost when notes came back,
IDs scattered, left off the track,
Now we map old to new with care,
Remapping spans with archive fare,
Restore restored, links everywhere! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: fixing note IDs in imported notes that contain note links, which directly addresses the core issue.
Linked Issues check ✅ Passed The changes implement the fix for issue #785 by capturing original IDs during backup import, remapping note:// links to new IDs, and updating spans accordingly.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the note link resolution issue during backup restoration; no unrelated modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Crustack Crustack merged commit 633c51e into main Jan 25, 2026
1 check passed
@Crustack Crustack deleted the fix/imported-note-links branch January 25, 2026 11:24
@coderabbitai coderabbitai Bot mentioned this pull request Feb 18, 2026
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.

Archived notes are no longer linked after restore

1 participant