mirror of
https://github.com/trezor/trezor-suite.git
synced 2026-03-14 11:18:56 +01:00
Revert "fix(suite-common): suite sync error type"
This reverts commit 666199c498.
This commit is contained in:
@@ -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 }));
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
},
|
||||
},
|
||||
|
||||
@@ -59,4 +59,4 @@ export const selectIsTurnOnSuiteSyncInteractionNeeded = (
|
||||
};
|
||||
|
||||
export const selectSuiteSyncError = (state: WithSuiteSyncAndDeviceState) =>
|
||||
!!state.suiteSync.suiteSyncError;
|
||||
state.suiteSync.suiteSyncError;
|
||||
|
||||
@@ -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';
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user