mirror of
https://github.com/trezor/trezor-suite.git
synced 2026-02-20 00:33:07 +01:00
fix(suite-sync): remove error on disabled QM
This commit is contained in:
committed by
Bohdan Juříček
parent
dfe2f51eee
commit
602b14f557
@@ -1,4 +1,3 @@
|
||||
import { QuotaManagerDisabledErrType } from '@suite-common/suite-sync-types';
|
||||
import { isDevEnv } from '@suite-common/suite-utils';
|
||||
|
||||
/**
|
||||
@@ -25,7 +24,3 @@ export const DEFAULT_QUOTA_MANAGER_URL = isDevEnv
|
||||
* Header used for signing add space to owner requests.
|
||||
*/
|
||||
export const EVOLU_SIGN_ADD_SPACE_TO_OWNER_REQUEST_HEADER = 'EvoluAddSpaceToOwnerV1';
|
||||
|
||||
export const QuotaManagerDisabled = (): QuotaManagerDisabledErrType => ({
|
||||
type: 'QuotaManagerDisabled',
|
||||
});
|
||||
|
||||
@@ -49,4 +49,4 @@ export {
|
||||
/**
|
||||
* Constants.
|
||||
*/
|
||||
export { DEFAULT_DEVICE_SIZE_QUOTA, QuotaManagerDisabled } from './constants';
|
||||
export { DEFAULT_DEVICE_SIZE_QUOTA } from './constants';
|
||||
|
||||
@@ -12,10 +12,7 @@ export type {
|
||||
RefreshSuiteSyncKeysDep,
|
||||
RefreshSuiteSyncKeysResult,
|
||||
} from './refreshSuiteSyncKeys';
|
||||
export type {
|
||||
QuotaManagerDisabledErrType,
|
||||
WriteModeRequiredForAllocationErrType,
|
||||
} from './quotaManagerTypes';
|
||||
export type { WriteModeRequiredForAllocationErrType } from './quotaManagerTypes';
|
||||
export type { TurnOffSuiteSyncDep, TurnOffSuiteSync } from './turnOffSuiteSync';
|
||||
export type { TurnOnSuiteSyncDep, TurnOnSuiteSync } from './turnOnSuiteSync';
|
||||
export type { SuiteSyncUnavailableOnDeviceErrorType } from './refreshSuiteSyncKeys';
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
export type WriteModeRequiredForAllocationErrType = {
|
||||
type: 'WriteModeRequiredForAllocation';
|
||||
};
|
||||
|
||||
export type QuotaManagerDisabledErrType = {
|
||||
type: 'QuotaManagerDisabled';
|
||||
};
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
import { Dispatch } from '@reduxjs/toolkit';
|
||||
|
||||
import {
|
||||
QuotaManagerDisabled,
|
||||
WriteModeRequiredForAllocation,
|
||||
ensureDeviceHasQuotaThunk,
|
||||
ensureOwnerHasAllocatedQuotaThunk,
|
||||
} from '@suite-common/suite-sync-quota-manager';
|
||||
import {
|
||||
QuotaManagerDisabledErrType,
|
||||
WriteModeRequiredForAllocationErrType,
|
||||
} from '@suite-common/suite-sync-types';
|
||||
import { WriteModeRequiredForAllocationErrType } from '@suite-common/suite-sync-types';
|
||||
import { DelegatedIdentityKey, SuiteSyncOwner } from '@suite-common/suite-types';
|
||||
import { isTrezorDeviceWithState, parseDeviceStaticSessionId } from '@suite-common/wallet-utils';
|
||||
import { StaticSessionId } from '@trezor/connect';
|
||||
@@ -34,7 +30,7 @@ export type EnsureQuotaParams = {
|
||||
|
||||
export type EnsureQuota = (
|
||||
params: EnsureQuotaParams,
|
||||
) => Promise<Result<void, WriteModeRequiredForAllocationErrType | QuotaManagerDisabledErrType>>;
|
||||
) => Promise<Result<void, WriteModeRequiredForAllocationErrType>>;
|
||||
|
||||
export type EnsureQuotaDep = {
|
||||
ensureQuota: EnsureQuota;
|
||||
@@ -47,15 +43,15 @@ export const createEnsureQuota =
|
||||
|
||||
const device = deps.getDeviceForStaticSessionId(deviceStaticSessionId);
|
||||
|
||||
if (!deps.getIsQuotaManagerEnabled()) {
|
||||
return err(QuotaManagerDisabled());
|
||||
if (device === null || !isNotNullOrUndefined(device.id)) {
|
||||
return ok();
|
||||
}
|
||||
|
||||
if (
|
||||
isNotNullOrUndefined(device?.id) &&
|
||||
deps.hasAllowance({ walletDescriptor, deviceId: device.id })
|
||||
deps.hasAllowance({ walletDescriptor, deviceId: device.id }) ||
|
||||
!deps.getIsQuotaManagerEnabled()
|
||||
) {
|
||||
return ok(undefined);
|
||||
return ok();
|
||||
}
|
||||
|
||||
if (isNotNull(device) && isTrezorDeviceWithState(device)) {
|
||||
@@ -83,5 +79,5 @@ export const createEnsureQuota =
|
||||
return err(WriteModeRequiredForAllocation());
|
||||
}
|
||||
|
||||
return ok(undefined);
|
||||
return ok();
|
||||
};
|
||||
|
||||
@@ -84,9 +84,9 @@ export const createEnsureStorage =
|
||||
isWriteMode,
|
||||
});
|
||||
|
||||
if (quotaResult.success || quotaResult.error.type === 'QuotaManagerDisabled') {
|
||||
if (quotaResult.success) {
|
||||
// Only set the relay URL for transport in case that quota manager is enabled or has quota for device.
|
||||
newStorage.updateRelayUrl(url);
|
||||
await newStorage.updateRelayUrl(url);
|
||||
}
|
||||
|
||||
deps.suiteSyncStorageRepository.set(storageId, newStorage);
|
||||
|
||||
Reference in New Issue
Block a user