Skip to content

Conversation

stevensJourney
Copy link
Contributor

@stevensJourney stevensJourney commented Mar 5, 2025

Overview

This fixes the sync status indicator which did not emit any updates for uploading or downloading.

Sync status updates for uploading or downloading can be quite fast. The demo has been updated to debounce the flow. A nicer UI might be to trigger some animation based off uploading/downloading.

status.mp4

@stevensJourney stevensJourney marked this pull request as ready for review March 5, 2025 15:49
@stevensJourney stevensJourney requested a review from simolus3 March 5, 2025 15:49
simolus3
simolus3 previously approved these changes Mar 5, 2025
Copy link
Contributor

@simolus3 simolus3 left a comment

Choose a reason for hiding this comment

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

These changes look good to me 👍

At least for the downloading state, we can write pretty accurate tests now. Something like this could go to SyncIntegrationTest.kt:

    @Test
    fun setsDownloadingState() = runTest {
        val syncStream = syncStream()
        database.connect(syncStream, 1000L)

        turbineScope(timeout = 10.0.seconds) {
            val turbine = database.currentStatus.asFlow().testIn(this)
            turbine.waitFor { it.connected && !it.downloading }

            syncLines.send(SyncLine.FullCheckpoint(Checkpoint(
                lastOpId = "1",
                checksums = listOf(BucketChecksum(
                    bucket = "bkt",
                    checksum = 0,
                ))
            )))
            turbine.waitFor { it.downloading }

            syncLines.send(SyncLine.CheckpointComplete(lastOpId = "1"))
            turbine.waitFor { !it.downloading }
            turbine.cancel()
        }

        database.close()
        syncLines.close()
    }

@stevensJourney stevensJourney merged commit cf4de2c into main Mar 6, 2025
3 checks passed
@stevensJourney stevensJourney deleted the sync-status-fix branch March 6, 2025 08:04
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