Skip to content

Optimize synchronization and enhance EntryDetailsScreen features#29

Merged
SmilingPixel merged 9 commits into
mainfrom
feat/sync_optimize_0529
Jun 9, 2026
Merged

Optimize synchronization and enhance EntryDetailsScreen features#29
SmilingPixel merged 9 commits into
mainfrom
feat/sync_optimize_0529

Conversation

@SmilingPixel

Copy link
Copy Markdown
Owner

This pull request introduces several enhancements and refactorings to the file management and diary entry UI features, with a focus on improved file statistics, sync usability, and code maintainability. The most significant changes include adding file size reporting to the file manager interfaces, surfacing file statistics in the entry details screen, refactoring sync initiation logic for better reusability, and simplifying the file fetcher factory and its tests.

File Management Enhancements:

  • Added a new getSize(fileName: String): Long method to the FileManager interface and implemented it for both LocalFileManager and InMemoryFileManager, enabling retrieval of file sizes. [1] [2] [3]

Entry Details UI Improvements:

  • The EntryDetailsScreen now displays statistics about the number of linked local files and their total size, using a new formatBytes utility for human-readable formatting. [1] [2] [3]
  • Added a cloud sync button with a progress indicator to the entry details screen, allowing users to initiate sync directly from the entry view. [1] [2]

Sync and UI Refactoring:

  • Refactored sync initiation logic in EntriesScreen for better code reuse and to enable sync from multiple UI locations. [1] [2]

File Fetcher Factory and Testing:

  • Extracted the core logic of LocalFileFetcher.Factory.create into a new createForUri method, simplifying usage and testing. Updated tests to use this method, removing unnecessary dependencies on platform context and image loader. [1] [2] [3] [4]

Sync Codec Robustness:

  • Removed legacy line-delimited entry decoding fallback from decodeEntryForSync, so only the current JSON-based format is supported for sync entry decoding. [1] [2]

- Implement entry statistics in the details view, showing character count, number of attached files, and total attachment size.
- Extend FileManager interface with a getSize method to support asynchronous file size calculation across platforms.
- Add a custom formatBytes utility for human-readable file sizes in Kotlin Multiplatform.
Copilot AI review requested due to automatic review settings June 3, 2026 01:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances diary entry UX and sync/file infrastructure by adding file-size reporting to the FileManager abstraction, surfacing local-file statistics in EntryDetailsScreen, and refactoring sync initiation so it can be triggered from both the list and entry-details screens. It also simplifies LocalFileFetcher.Factory testing by extracting a createForUri helper, and removes the legacy line-delimited sync decode fallback in favor of JSON-only decoding.

Changes:

  • Add FileManager.getSize(...) (and implementations) and use it to display local-file count/size stats in EntryDetailsScreen (plus a byte formatter).
  • Refactor cloud sync initiation in EntriesScreen and expose a sync action/progress indicator on EntryDetailsScreen.
  • Simplify LocalFileFetcher.Factory construction/testing via createForUri, and tighten sync decoding to JSON-only.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
composeApp/src/commonMain/kotlin/io/github/smiling_pixel/filesystem/FileManager.kt Adds getSize to the FileManager API and implements it for LocalFileManager.
composeApp/src/commonMain/kotlin/io/github/smiling_pixel/filesystem/InMemoryFileManager.kt Implements getSize for the in-memory file manager (for tests/wasm).
composeApp/src/commonMain/kotlin/io/github/smiling_pixel/filesystem/LocalFileFetcher.kt Extracts Factory.createForUri to simplify call sites/tests.
composeApp/src/commonTest/kotlin/io/github/smiling_pixel/filesystem/LocalFileFetcherTest.kt Updates tests to use createForUri directly (less platform setup).
composeApp/src/commonMain/kotlin/io/github/smiling_pixel/screens/EntriesScreen.kt Refactors sync logic into a reusable lambda and passes sync state/actions into entry details.
composeApp/src/commonMain/kotlin/io/github/smiling_pixel/screens/EntryDetailsScreen.kt Adds entry-level sync button/progress and displays content/local-file statistics with byte formatting.
composeApp/src/commonMain/kotlin/io/github/smiling_pixel/sync/SyncManager.kt Removes legacy line-delimited fallback in decodeEntryForSync (JSON-only).
composeApp/src/commonTest/kotlin/io/github/smiling_pixel/sync/SyncManagerCodecTest.kt Updates codec test payload to JSON to match the new decode behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@SmilingPixel
SmilingPixel merged commit 5516208 into main Jun 9, 2026
3 checks passed
@SmilingPixel
SmilingPixel deleted the feat/sync_optimize_0529 branch June 9, 2026 02:49
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.

2 participants