From ecb580307caababbffae564ebb4fcbde0bb14fc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bohdan=20Ju=C5=99=C3=AD=C4=8Dek?= <36101761+juriczech@users.noreply.github.com> Date: Wed, 28 Jan 2026 17:28:58 +0100 Subject: [PATCH] Revert "fix(suite-common): suite sync error type" This reverts commit 666199c498180c0b693eadaf2e69d518507c1241. --- .../storage/createEnsureWalletSuiteSyncOn.ts | 24 +++++-------------- .../suite-sync/src/suiteSyncReducer.ts | 9 ++----- .../suite-sync/src/suiteSyncSelectors.ts | 2 +- .../screens/HomeScreen/homescreenSelectors.ts | 16 ++++--------- 4 files changed, 14 insertions(+), 37 deletions(-) diff --git a/suite-common/suite-sync/src/storage/createEnsureWalletSuiteSyncOn.ts b/suite-common/suite-sync/src/storage/createEnsureWalletSuiteSyncOn.ts index 762776e310..97c705fe51 100644 --- a/suite-common/suite-sync/src/storage/createEnsureWalletSuiteSyncOn.ts +++ b/suite-common/suite-sync/src/storage/createEnsureWalletSuiteSyncOn.ts @@ -8,7 +8,7 @@ import { } from '@suite-common/suite-sync-types'; import { selectDeviceByStaticSessionId } from '@suite-common/wallet-core'; import { isTrezorDeviceWithState } from '@suite-common/wallet-utils'; -import { err, exhaustive } from '@trezor/type-utils'; +import { err } from '@trezor/type-utils'; import { setSuiteSyncError } from '../suiteSyncReducer'; import { isFwUpgradeNeededForSuiteSync, isSuiteSyncSupportedByDevice } from '../suiteSyncUtils'; @@ -38,23 +38,11 @@ export const createEnsureWalletSuiteSyncOn = const result = await deps.ensureSuiteSyncData({ deviceStaticSessionId }); - if (!result.success) { - const { type } = result.error; - - switch (type) { - case 'DeviceCancelled': - case 'DeviceError': - deps.dispatch(setSuiteSyncError({ error: result.error })); - break; - - case 'SuiteSyncUnavailableOnDeviceError': - // This error is now not handled in the UI, so we don't need to set the error. It will probably be added as a follow up. - deps.dispatch(setSuiteSyncError({ error: null })); - break; - - default: - exhaustive(type); - } + if ( + !result.success && + (result.error.type === 'DeviceCancelled' || result.error.type === 'DeviceError') + ) { + deps.dispatch(setSuiteSyncError({ error: result.error.type })); } else { deps.dispatch(setSuiteSyncError({ error: null })); } diff --git a/suite-common/suite-sync/src/suiteSyncReducer.ts b/suite-common/suite-sync/src/suiteSyncReducer.ts index b25b05d8d6..fb248582a0 100644 --- a/suite-common/suite-sync/src/suiteSyncReducer.ts +++ b/suite-common/suite-sync/src/suiteSyncReducer.ts @@ -1,7 +1,5 @@ import { PayloadAction, createSlice } from '@reduxjs/toolkit'; -import { DeviceCancelledErrType, DeviceErrorType } from '@suite-common/wallet-types'; - export type SuiteSyncSettings = { /** * This is flag to show some extra Debug UI. @@ -27,7 +25,7 @@ export type SuiteSyncSettings = { export type SuiteSyncState = { settings: SuiteSyncSettings; - suiteSyncError: DeviceErrorType | DeviceCancelledErrType | null; + suiteSyncError: string | null; }; export const initialSuiteSyncState: SuiteSyncState = { @@ -55,10 +53,7 @@ export const suiteSyncSlice = createSlice({ setSuiteSyncRelayUrl: (state, { payload }: PayloadAction<{ url: string | null }>) => { state.settings.suiteSyncRelayUrl = payload.url; }, - setSuiteSyncError: ( - state, - { payload }: PayloadAction<{ error: DeviceErrorType | DeviceCancelledErrType | null }>, - ) => { + setSuiteSyncError: (state, { payload }: PayloadAction<{ error: string | null }>) => { state.suiteSyncError = payload.error; }, }, diff --git a/suite-common/suite-sync/src/suiteSyncSelectors.ts b/suite-common/suite-sync/src/suiteSyncSelectors.ts index 107ffc2b4c..5c3578849b 100644 --- a/suite-common/suite-sync/src/suiteSyncSelectors.ts +++ b/suite-common/suite-sync/src/suiteSyncSelectors.ts @@ -59,4 +59,4 @@ export const selectIsTurnOnSuiteSyncInteractionNeeded = ( }; export const selectSuiteSyncError = (state: WithSuiteSyncAndDeviceState) => - !!state.suiteSync.suiteSyncError; + state.suiteSync.suiteSyncError; diff --git a/suite-native/module-home/src/screens/HomeScreen/homescreenSelectors.ts b/suite-native/module-home/src/screens/HomeScreen/homescreenSelectors.ts index 9887e40d82..f3c218a16d 100644 --- a/suite-native/module-home/src/screens/HomeScreen/homescreenSelectors.ts +++ b/suite-native/module-home/src/screens/HomeScreen/homescreenSelectors.ts @@ -3,7 +3,6 @@ import { createWeakMapSelector } from '@suite-common/redux-utils'; import { WithSuiteSyncState, selectIsTurnOnSuiteSyncInteractionNeeded, - selectSuiteSyncError, } from '@suite-common/suite-sync'; import { DeviceRootState, @@ -50,13 +49,8 @@ export const selectShouldDisplayUpgradeFirmwareAlert = createMemoizedSelector( isFirmwareUpdateFeatureEnabled, ); -export const selectShouldDisplaySuiteSyncAlert = createMemoizedSelector( - [ - selectSuiteSyncError, - selectIsDeviceConnected, - (state: WithSuiteSyncState & DeviceRootState) => - selectIsTurnOnSuiteSyncInteractionNeeded(state, selectDeviceStaticSessionId(state)), - ], - (suiteSyncError, isDeviceConnected, interactionNeeded) => - interactionNeeded === 'keys-needed' && (!!suiteSyncError || !isDeviceConnected), -); +export const selectShouldDisplaySuiteSyncAlert = (state: WithSuiteSyncState & DeviceRootState) => { + const deviceStaticSessionId = selectDeviceStaticSessionId(state); + + return selectIsTurnOnSuiteSyncInteractionNeeded(state, deviceStaticSessionId) === 'keys-needed'; +};