Merged
Conversation
…ructure
- Moved NotesListScreen.tsx → ListNotes/index.tsx (344 lines)
- Extracted 7 focused components:
- NoteSkeletonItem: skeleton loading UI
- FilterSortSheet: filter/sort modal
- CreateFolderSheet: folder creation modal
- NoteListItem: individual note rendering
- SubfoldersList: folder grid/list view
- NotesHeader: notes section header
- EmptyState: empty search state
- Extracted 3 custom hooks:
- useNotesFiltering: filtering & sorting logic
- useFolderPaths: folder path calculation
- useNotesLoader: notes loading & decryption
- Created utils/noteUtils.ts for shared utilities
- Fixed TypeScript error in folder-notes.tsx viewType casting
- Removed all unused imports and styles
## Core Features ### Offline-First Data Layer - SQLite database for local note and folder caching - Stale-while-revalidate pattern for instant UI updates - Conditional HTTP requests (ETag/Last-Modified) to minimize data transfer - Configurable cache preference: decrypted (instant) vs encrypted (secure) ### Background Sync System - Mutation queue in SQLite for offline changes - Auto-sync on network reconnect with race condition protection - Retry logic with exponential backoff for failed syncs - Optimistic UI updates with temp IDs for offline note creation ### Network Management - Network status detection with @react-native-community/netinfo - Orange floating offline indicator - Disabled edit/delete when offline (create notes offline enabled) - Clear user feedback with offline alerts ### User Settings - Cache preference bottom sheet (replaced toggle) - "Cache Decrypted" - instant loading, requires master password - "Cache Encrypted" - maximum security, slightly slower ## Technical Improvements ### API Layer - Enhanced HTTP client with conditional request support - Database cache layer with metadata tracking - Folder and note APIs with offline fallback - Type-safe SQLite bindings with proper null handling ### UI/UX - Fixed settings toggle switch positioning (16px → 20px translation) - Better cache preference explanations with radio buttons
Performance Optimizations: - Consolidate SQL queries from 5 separate queries to 1 optimized query (~80% reduction) - Add composite database indexes for count queries (O(log n) instead of O(n) lookups) - Implement 10s short-lived cache for offline counts to prevent recalculation - Add helper functions to eliminate code duplication (112 lines deduplicated) Bug Fixes: - Fix folder counts not displaying when offline (calculate from SQLite cache) - Fix race condition in ViewNote attachment loading with proper cleanup - Fix infinite error toasts when viewing notes offline - Improve error handling to return complete interfaces UX Improvements: - Add 500ms debouncing for network status changes (prevents flaky connection issues) - Add prefetch during master password authentication for instant offline access - Add two-stage loading UI: "Securing Your Data" → "Caching Your Data" - Add loading spinner to prevent white screen flash Security: - Change default to encrypted cache for better security (decrypt on-demand) - Add "Offline Cache Security" documentation in Settings - Maintain end-to-end encryption throughout
Contributor
|
🎉 This PR is included in version 1.31.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Issues attributed to commits in this pull requestThis pull request was merged and Sentry observed the following issues:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR completes the offline-first architecture implementation with significant performance optimizations and bug
fixes:
Performance Optimizations
trips)
Bug Fixes
UX Improvements
Security
Technical Details
Modified Files:
apps/mobile/v1/src/services/api/notes.ts- Optimized count calculations with cachingapps/mobile/v1/src/lib/database/index.ts- Added composite indexesapps/mobile/v1/src/screens/ViewNote/index.tsx- Fixed race conditionsapps/mobile/v1/src/screens/FoldersScreen.tsx- Added network status debouncingapps/mobile/v1/src/hooks/useMasterPassword.ts- Added prefetch logicapps/mobile/v1/src/components/MasterPasswordDialog/*- Two-stage loading UITest Plan