Simplify redux ducks and avoid reexport

This commit is contained in:
Fedor Indutny 2023-04-07 10:46:00 -07:00 committed by GitHub
parent bd41d7b216
commit d34d187f1e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 144 additions and 94 deletions

View file

@ -5,6 +5,7 @@ import { createSelector } from 'reselect';
import { isInteger } from 'lodash';
import { ITEM_NAME as UNIVERSAL_EXPIRE_TIMER_ITEM } from '../../util/universalExpireTimer';
import { SecurityNumberIdentifierType } from '../../util/safetyNumber';
import { innerIsBucketValueEnabled } from '../../RemoteConfig';
import type { ConfigKeyType, ConfigMapType } from '../../RemoteConfig';
import type { StateType } from '../reducer';
@ -145,6 +146,25 @@ export const getContactManagementEnabled = createSelector(
}
);
export const getSecurityNumberIdentifierType = createSelector(
getRemoteConfig,
(_state: StateType, { now }: { now: number }) => now,
(remoteConfig: ConfigMapType, now: number): SecurityNumberIdentifierType => {
if (isRemoteConfigFlagEnabled(remoteConfig, 'desktop.safetyNumberUUID')) {
return SecurityNumberIdentifierType.UUIDIdentifier;
}
const timestamp = remoteConfig['desktop.safetyNumberUUID.timestamp']?.value;
if (typeof timestamp !== 'number') {
return SecurityNumberIdentifierType.E164Identifier;
}
return now >= timestamp
? SecurityNumberIdentifierType.UUIDIdentifier
: SecurityNumberIdentifierType.E164Identifier;
}
);
export const getDefaultConversationColor = createSelector(
getItems,
(