|
1 |
| -import { isBoolean } from 'lodash'; |
| 1 | +import { isArray, isBoolean } from 'lodash'; |
2 | 2 | import type { SessionFlagsKeys } from '../../../state/ducks/types/releasedFeaturesReduxTypes';
|
3 | 3 | import { Flex } from '../../basic/Flex';
|
4 | 4 | import { SessionToggle } from '../../basic/SessionToggle';
|
5 | 5 | import { HintText, SpacerSM, SpacerXS } from '../../basic/Text';
|
6 | 6 | import { DEBUG_FEATURE_FLAGS } from './constants';
|
7 | 7 | import { ConvoHub } from '../../../session/conversations';
|
8 | 8 | import { isDebugMode } from '../../../shared/env_vars';
|
| 9 | +import { ProMessageFeature } from '../../../models/proMessageFeature'; |
9 | 10 |
|
10 | 11 | type FeatureFlagToggleType = {
|
11 | 12 | forceUpdate: () => void;
|
@@ -104,25 +105,48 @@ export const FeatureFlags = ({
|
104 | 105 | return null;
|
105 | 106 | }
|
106 | 107 |
|
107 |
| - if (!isBoolean(value)) { |
| 108 | + if (isBoolean(value)) { |
| 109 | + return <FlagToggle forceUpdate={forceUpdate} flag={flag} value={value} />; |
| 110 | + } |
| 111 | + if (isArray(value) && flag === 'mockMessageProFeatures') { |
| 112 | + const rotateMsgProFeat = () => { |
| 113 | + if (value.length === 0) { |
| 114 | + window.sessionFeatureFlags.mockMessageProFeatures = [ProMessageFeature.PRO_BADGE]; |
| 115 | + } else if (value.length === 1) { |
| 116 | + if (value[0] === ProMessageFeature.PRO_BADGE) { |
| 117 | + window.sessionFeatureFlags.mockMessageProFeatures = [ |
| 118 | + ProMessageFeature.PRO_ANIMATED_DISPLAY_PICTURE, |
| 119 | + ]; |
| 120 | + } else if (value[0] === ProMessageFeature.PRO_ANIMATED_DISPLAY_PICTURE) { |
| 121 | + window.sessionFeatureFlags.mockMessageProFeatures = [ |
| 122 | + ProMessageFeature.PRO_INCREASED_MESSAGE_LENGTH, |
| 123 | + ]; |
| 124 | + } else if (value[0] === ProMessageFeature.PRO_INCREASED_MESSAGE_LENGTH) { |
| 125 | + window.sessionFeatureFlags.mockMessageProFeatures = [ |
| 126 | + ProMessageFeature.PRO_BADGE, |
| 127 | + ProMessageFeature.PRO_ANIMATED_DISPLAY_PICTURE, |
| 128 | + ProMessageFeature.PRO_INCREASED_MESSAGE_LENGTH, |
| 129 | + ]; |
| 130 | + } |
| 131 | + } else if (value.length === 3) { |
| 132 | + window.sessionFeatureFlags.mockMessageProFeatures = []; |
| 133 | + } |
| 134 | + forceUpdate(); |
| 135 | + }; |
108 | 136 | return (
|
109 |
| - <> |
110 |
| - <h3>{flag}</h3> |
111 |
| - {Object.entries(value).map(([k, v]: [string, FlagValues]) => { |
112 |
| - const nestedFlag = k as SessionFlagsKeys; |
113 |
| - return ( |
114 |
| - <FlagToggle |
115 |
| - flag={nestedFlag} |
116 |
| - value={v} |
117 |
| - parentFlag={flag} |
118 |
| - forceUpdate={forceUpdate} |
119 |
| - /> |
120 |
| - ); |
121 |
| - })} |
122 |
| - </> |
| 137 | + <Flex |
| 138 | + $container={true} |
| 139 | + $alignItems="center" |
| 140 | + $flexDirection="row" |
| 141 | + style={{ cursor: 'pointer', gap: 'var(--margins-xs)' }} |
| 142 | + onClick={rotateMsgProFeat} |
| 143 | + > |
| 144 | + <div>{flag}</div> |
| 145 | + <pre style={{ overflow: 'hidden' }}>{JSON.stringify(value)}</pre> |
| 146 | + </Flex> |
123 | 147 | );
|
124 | 148 | }
|
125 |
| - return <FlagToggle forceUpdate={forceUpdate} flag={flag} value={value} />; |
| 149 | + throw new Error('Feature flag is not a boolean or array'); |
126 | 150 | })}
|
127 | 151 | <SpacerSM />
|
128 | 152 | </Flex>
|
|
0 commit comments