Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: introduce improved sync screen experience #619

Merged
merged 14 commits into from
Aug 26, 2024

Conversation

achou11
Copy link
Member

@achou11 achou11 commented Aug 22, 2024

Closes #550
Closes #602
Closes #603
Closes #604
Towards #605
Closes #610

Important notes:

  • There is a bug where sync can occur without opt-in by connected peers. This is backend-related (see Sync can unexpectedly occur with devices that have not enabled it comapeo-core#762).

  • Upgrades core to latest alpha version, which introduces a new sync state api and also the ability to set/configure sync autostopping

  • This PR does not change the behavior related to sync being turned off when leaving the screen. I think that can/should be a follow-up PR that also introduces auto-stopping sync when leaving the screen after being fully synced.


Not an exhaustive showcase of all of the states (hard to do with just 2 devices)

  • No connected devices
01-sync-alone.mov
  • Connected devices, but no data to sync
02-sync-no-data.mov
  • Connected devices, data to sync
03-sync-with-data.mp4

Copy link
Contributor

@EvanHahn EvanHahn left a comment

Choose a reason for hiding this comment

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

Didn't review the UI code too heavily but this LGTM!


// Remove devices from #perDeviceMaxSyncCount that are no longer found in the new sync state
for (const deviceId of this.#perDeviceMaxSyncCount.keys()) {
if (!connectedDevices.includes(deviceId)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: this is O(N) but could be O(1).

Suggested change
if (!connectedDevices.includes(deviceId)) {
if (!Object.hasOwn(state.remoteDeviceSyncState, deviceId)) {

(Is this the first time Big O notation has ever been relevant in my career? For this tiny nitpick?)

Copy link
Member Author

Choose a reason for hiding this comment

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

addressed via 235dd9b

WifiIcon,
} from '../../sharedComponents/icons';

type SyncStage =
Copy link
Contributor

Choose a reason for hiding this comment

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

Love this.

Comment on lines 335 to 336
// @ts-expect-error
throw new Error(`Invalid status: ${syncStage.status}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: consider ExhaustivenessError. Same comment applies to the switch below.

Copy link
Member Author

Choose a reason for hiding this comment

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

addressed via b11818b

</Text>
)}
</View>
);
}

function deriveSyncStage({
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like this could be useful to test? Wrote tests in this gist.

Copy link
Member Author

Choose a reason for hiding this comment

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

addressed via cccd6df

@achou11 achou11 merged commit e90cdbc into develop Aug 26, 2024
3 checks passed
@achou11 achou11 deleted the ac/sync-screen-improvements branch August 26, 2024 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants