1 import type { SharedStartListening } from '@proton/redux-shared-store-types';
2 import noop from '@proton/utils/noop';
4 import type { OrganizationState } from '../organization';
5 import { selectOrganization } from '../organization';
8 * Listen to subscription changes and update unleash feature flags after change.
10 export const startListeningToPlanNameChange = (startListening: SharedStartListening<OrganizationState>) => {
12 predicate: (_, currentState, previousState) => {
13 const oldValue = selectOrganization(previousState);
14 const newValue = selectOrganization(currentState);
15 return !!(oldValue.meta.fetchedAt && oldValue.value?.PlanName !== newValue.value?.PlanName);
17 effect: (_, listenerApi) => {
18 listenerApi.extra.unleashClient.stop();
19 listenerApi.extra.unleashClient.start().catch(noop);