Skip to content

feat: support sync via Google Drive#18

Open
SmilingPixel wants to merge 9 commits intomainfrom
feat/cloud_sync_0316
Open

feat: support sync via Google Drive#18
SmilingPixel wants to merge 9 commits intomainfrom
feat/cloud_sync_0316

Conversation

@SmilingPixel
Copy link
Copy Markdown
Owner

This pull request introduces a comprehensive cloud synchronization feature for diary entries, enabling users to sync their data with Google Drive. The sync can be triggered manually from the UI or automatically at regular intervals, and users can configure sync preferences in the settings screen. The implementation includes cross-platform support for auto-sync, robust conflict resolution logic, and user feedback on sync status.

The most important changes are:

Cloud Sync Core Logic:

  • Added a new performCloudSync function in SyncManager.kt that handles uploading, downloading, and conflict resolution of diary entries between local storage and Google Drive, including utility functions for encoding/decoding entries and managing folders.
  • Introduced a SyncResult data class to summarize sync outcomes (uploaded, downloaded, unchanged entries).

Auto Sync Infrastructure:

  • Implemented platform-specific startAutoSync functions for Android and JVM, which periodically trigger synchronization in the background if enabled in settings. [1] [2] [3]

User Interface Enhancements:

  • Added a manual sync button and feedback dialogs (progress, summary, error) to the EntriesScreen, allowing users to trigger and monitor sync operations from the main UI. [1] [2]
  • Updated the SettingsScreen to allow users to enable/disable cloud sync and auto-sync, specify the cloud sync path, and view connection status to Google Drive. [1] [2] [3] [4]

Settings & Preferences:

  • Extended the SettingsRepository interface to support cloud sync preferences (isCloudSyncEnabled, isAutoSyncEnabled, cloudSyncPath) and their corresponding setters.

Codebase & Import Updates:

  • Added necessary imports and minor code adjustments in relevant files to support the new sync logic and UI changes. [1] [2] [3] [4]

These changes collectively provide robust, user-configurable cloud synchronization for diary entries, improving data safety and accessibility across devices.

Copilot AI review requested due to automatic review settings March 30, 2026 01:54
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 adds Google Drive–backed cloud synchronization for diary entries, including manual sync from the entries UI, configurable sync settings (enable/disable, auto-sync toggle, sync path), and platform-specific auto-sync starters.

Changes:

  • Added common sync engine (performCloudSync) with encoding/decoding and Drive folder/path handling.
  • Implemented platform-specific startAutoSync for Android/JVM/Wasm and wired auto-sync startup from EntriesScreen.
  • Extended settings/preferences + updated Settings/Entries UI to configure and trigger sync with status dialogs.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
composeApp/src/commonMain/kotlin/io/github/smiling_pixel/sync/SyncManager.kt Implements Google Drive sync workflow, conflict checks, and entry serialization helpers.
composeApp/src/commonMain/kotlin/io/github/smiling_pixel/sync/AutoSync.kt Declares the expect API for platform-specific auto-sync.
composeApp/src/androidMain/kotlin/io/github/smiling_pixel/sync/AutoSync.android.kt Adds Android background periodic auto-sync loop.
composeApp/src/jvmMain/kotlin/io/github/smiling_pixel/sync/AutoSync.jvm.kt Adds JVM background periodic auto-sync loop.
composeApp/src/wasmJsMain/kotlin/io/github/smiling_pixel/sync/AutoSync.wasmJs.kt Provides Wasm no-op/unsupported auto-sync implementation.
composeApp/src/commonMain/kotlin/io/github/smiling_pixel/preference/SettingsRepository.kt Extends settings contract with cloud sync + auto-sync + path.
composeApp/src/nonWebMain/kotlin/io/github/smiling_pixel/preference/DataStoreSettingsRepository.kt Persists new cloud sync settings in DataStore for non-web targets.
composeApp/src/wasmJsMain/kotlin/io/github/smiling_pixel/preference/SettingsRepository.wasmJs.kt Persists new cloud sync settings in localStorage for Wasm/JS.
composeApp/src/commonMain/kotlin/io/github/smiling_pixel/screens/SettingsScreen.kt Adds UI to connect to Drive and configure cloud sync settings.
composeApp/src/commonMain/kotlin/io/github/smiling_pixel/screens/EntriesScreen.kt Adds manual sync FAB + dialogs and starts auto-sync on screen load.

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

Comment on lines 8 to 11
import kotlinx.datetime.TimeZone
import kotlinx.datetime.toLocalDateTime
import kotlinx.datetime.LocalDate
import androidx.compose.runtime.collectAsState
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

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

kotlinx.datetime.LocalDate is imported but not used in this file. Please remove the unused import to keep the file warning-free (and avoid failures if warnings-as-errors/linting is enabled).

Copilot uses AI. Check for mistakes.
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.

3 participants