Conversation
0bbaf04 to
6002ee2
Compare
dec9f2e to
7e05e39
Compare
There was a problem hiding this comment.
Pull request overview
Adds a cross-app “sync error” indicator by centralizing account sync error/outdated detection in @ledgerhq/live-common, then consuming it from mobile (TopBar warning + bottom sheet) and desktop (refactor to shared hook while keeping analytics/FSM behavior).
Changes:
- Added shared
useAccountsSyncStatushook (with unit tests) to compute sync-error / out-of-date accounts from batch sync state. - Mobile TopBar: new
useSyncIndicator, sync warning icon + loading state, and aSyncErrorBottomSheetto show impacted accounts; updated tests and i18n strings. - Desktop: refactored sync status hook and up-to-date selector logic to reuse
live-commonutilities; updated unit tests accordingly.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| libs/ledger-live-common/src/bridge/react/useAccountsSyncStatus.ts | New shared hook to compute accounts with sync errors/outdated state + last sync timestamp. |
| libs/ledger-live-common/src/bridge/react/useAccountsSyncStatus.test.ts | Unit tests covering multiple sync/outdated/pending scenarios for the shared hook. |
| libs/ledger-live-common/src/bridge/react/index.ts | Exposes the new shared hook via the bridge/react barrel export. |
| apps/ledger-live-mobile/src/reducers/accounts.ts | Adds selector to provide { account, isUpToDate } objects for the shared hook. |
| apps/ledger-live-mobile/src/mvvm/components/TopBar/useTopBarViewModel.ts | Wires sync indicator state + drawer state into the TopBar ViewModel (MVVM). |
| apps/ledger-live-mobile/src/mvvm/components/TopBar/index.tsx | Passes new sync-related props from ViewModel to TopBarView. |
| apps/ledger-live-mobile/src/mvvm/components/TopBar/hooks/useSyncIndicator.ts | New hook combining account sync status + polling/global sync to derive error/pending UI state. |
| apps/ledger-live-mobile/src/mvvm/components/TopBar/components/SyncErrorBottomSheet.tsx | New bottom sheet UI showing impacted accounts when sync warning is pressed. |
| apps/ledger-live-mobile/src/mvvm/components/TopBar/TopBarView/index.tsx | Renders the sync warning action icon (with loading) and displays the bottom sheet. |
| apps/ledger-live-mobile/src/mvvm/components/CustomTopBar/index.tsx | Adds loading support to TopBar action icons. |
| apps/ledger-live-mobile/src/mvvm/components/TopBar/tests/TopBarView.test.tsx | Extends unit tests for sync icon visibility and updates icon mocks. |
| apps/ledger-live-mobile/src/mvvm/components/TopBar/integrations/TopBar.integration.test.tsx | Adds integration coverage for sync icon visibility in TopBar. |
| apps/ledger-live-mobile/src/screens/Swap/LiveApp/components/tests/useSwapTopBarHeaderViewModel.test.ts | Updates mocked TopBar VM shape to include sync indicator props. |
| apps/ledger-live-mobile/src/locales/en/common.json | Adds English strings for sync indicator accessibility labels and bottom sheet copy. |
| apps/ledger-live-desktop/src/renderer/reducers/accounts.ts | Simplifies up-to-date computation by delegating to isUpToDateAccount. |
| apps/ledger-live-desktop/src/mvvm/components/TopBar/hooks/useAccountsSyncStatus.ts | Refactors desktop hook to delegate detection to shared live-common hook, keeping analytics. |
| apps/ledger-live-desktop/src/mvvm/components/TopBar/hooks/tests/useAccountsSyncStatus.test.ts | Updates tests to mock the new shared hook and validate deduped tracking behavior. |
| apps/ledger-live-desktop/src/mvvm/components/TopBar/hooks/useActivityIndicator.ts | Removes outdated comment (no functional change). |
apps/ledger-live-mobile/src/mvvm/components/TopBar/__integrations__/TopBar.integration.test.tsx
Show resolved
Hide resolved
apps/ledger-live-mobile/src/mvvm/components/TopBar/components/SyncErrorBottomSheet/index.tsx
Show resolved
Hide resolved
d2e1504 to
4359299
Compare
4359299 to
7d1d86e
Compare
|
7d1d86e to
f4e1c86
Compare
f4e1c86 to
589cfe1
Compare
285b580 to
c424d79
Compare
| ); | ||
|
|
||
| const batchState = useBatchAccountsSyncState({ accounts: allAccounts }); | ||
| const errorTickers: string[] = []; |
There was a problem hiding this comment.
we should keep this because for example if we have ETH/BTC/ETH
2 ETH accounts we want to track it. We don't want to deduplicate the analytics
c424d79 to
0605ef8
Compare
apps/ledger-live-mobile/src/mvvm/components/TopBar/hooks/useSyncIndicator.ts
Show resolved
Hide resolved
apps/ledger-live-desktop/src/mvvm/components/TopBar/hooks/useAccountsSyncStatus.ts
Show resolved
Hide resolved
0605ef8 to
2943437
Compare
|




✅ Checklist
npx changesetwas attached.live-commonuseAccountsSyncStatushook mutualized inlive-common📝 Description
Implements the sync indicator feature on mobile and mutualizes sync error detection logic between desktop and mobile.
Shared layer (
live-common)useAccountsSyncStatushook inbridge/react/— takes an array ofAccountWithUpToDateCheckand returns which accounts have sync errors or are outdated, usinguseBatchAccountsSyncStateunder the hood.isUpToDatecomputation to the existingisUpToDateAccountutility from@ledgerhq/live-common/account, removing duplicated inline logic.Mobile
useSyncIndicatorhook combininguseAccountsSyncStatus,useCountervaluesPolling, anduseGlobalSyncStateto derive sync status (isError,isPending).TopBarViewdisplays aWarningicon when accounts exist and sync has errors, with optional loading state when sync is pending.SyncErrorBottomSheetcomponent shows affected account names when the sync icon is pressed.isSyncDrawerOpen) managed in the ViewModel for MVVM compliance.CustomTopBar'sTopBarActionIconnow supports aloadingprop.accountsWithUpToDateCheckSelectorin mobile's accounts reducer.Desktop
useAccountsSyncStatusto delegate to the shared hook fromlive-common, keeping desktop-specific analytics tracking (SyncErrorevent) and ticker-based error formatting.getEnvimport from accounts reducer.useSyncLifecycle) is preserved — the shared hook only handles error detection, not UI state transitions.Tests
useAccountsSyncStatushook (6 cases inlive-common).TopBarView.test.tsx— sync icon visibility tests (3 cases).TopBar.integration.test.tsx— sync indicator integration tests (3 cases),useSyncIndicatoris mocked to isolate TopBar component behavior.useSwapTopBarHeaderViewModel.test.tsmock to include new sync props.❓ Context
🧐 Checklist for the PR Reviewers