Optimize synchronization and enhance EntryDetailsScreen features#29
Merged
Conversation
- 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.
Contributor
There was a problem hiding this comment.
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 inEntryDetailsScreen(plus a byte formatter). - Refactor cloud sync initiation in
EntriesScreenand expose a sync action/progress indicator onEntryDetailsScreen. - Simplify
LocalFileFetcher.Factoryconstruction/testing viacreateForUri, 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.
Co-authored-by: Copilot <copilot@github.com>
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.
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:
getSize(fileName: String): Longmethod to theFileManagerinterface and implemented it for bothLocalFileManagerandInMemoryFileManager, enabling retrieval of file sizes. [1] [2] [3]Entry Details UI Improvements:
EntryDetailsScreennow displays statistics about the number of linked local files and their total size, using a newformatBytesutility for human-readable formatting. [1] [2] [3]Sync and UI Refactoring:
EntriesScreenfor better code reuse and to enable sync from multiple UI locations. [1] [2]File Fetcher Factory and Testing:
LocalFileFetcher.Factory.createinto a newcreateForUrimethod, 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:
decodeEntryForSync, so only the current JSON-based format is supported for sync entry decoding. [1] [2]