Skip to content

Commit

Permalink
fix(suite): respect feature flag on CoinjoinClient start
Browse files Browse the repository at this point in the history
(cherry picked from commit c86fe60)
  • Loading branch information
szymonlesisz authored and marekrjpolak committed May 13, 2024
1 parent d759b16 commit 32f7c90
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions packages/suite/src/actions/wallet/coinjoinClientActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import * as COINJOIN from './constants/coinjoinConstants';
import { AddressDisplayOptions } from '@suite-common/wallet-types';

import { selectAddressDisplayType } from 'src/reducers/suite/suiteReducer';
import { Feature, selectIsFeatureDisabled } from '@suite-common/message-system';

const clientEnable = (symbol: Account['symbol']) =>
({
Expand Down Expand Up @@ -732,12 +733,17 @@ export const initCoinjoinService =
if (knownService && knownClient?.status === 'loaded') {
return knownService;
}

const isCoinjoinDisabledByFeatureFlag = selectIsFeatureDisabled(state, Feature.coinjoin);
// retry if client was not enabled properly until now
if (knownService && knownClient?.status === 'unavailable') {
const status = await knownService.client.enable();
if (status.success) {
dispatch(clientEnableSuccess(symbol, status));
if (!isCoinjoinDisabledByFeatureFlag) {
const status = await knownService.client.enable();
if (status.success) {
dispatch(clientEnableSuccess(symbol, status));
}
}

return knownService;
}

Expand Down Expand Up @@ -787,6 +793,11 @@ export const initCoinjoinService =
prison,
environment,
});
if (isCoinjoinDisabledByFeatureFlag) {
dispatch(clientEnableFailed(symbol));

return service;
}
const { client } = service;
const status = await client.enable();
// handle status change
Expand Down

0 comments on commit 32f7c90

Please sign in to comment.