Add "should show badges" feature flag
This commit is contained in:
parent
dd342e1f22
commit
ab543aea93
5 changed files with 29 additions and 3 deletions
|
@ -24,6 +24,7 @@ export type ConfigKeyType =
|
||||||
| 'desktop.senderKey.send'
|
| 'desktop.senderKey.send'
|
||||||
| 'desktop.senderKey.retry'
|
| 'desktop.senderKey.retry'
|
||||||
| 'desktop.sendSenderKey3'
|
| 'desktop.sendSenderKey3'
|
||||||
|
| 'desktop.showUserBadges'
|
||||||
| 'desktop.storage'
|
| 'desktop.storage'
|
||||||
| 'desktop.storageWrite3'
|
| 'desktop.storageWrite3'
|
||||||
| 'desktop.usernames'
|
| 'desktop.usernames'
|
||||||
|
|
16
ts/badges/shouldShowBadges.ts
Normal file
16
ts/badges/shouldShowBadges.ts
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
// Copyright 2021 Signal Messenger, LLC
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
import { isEnabled } from '../RemoteConfig';
|
||||||
|
import { getEnvironment, Environment } from '../environment';
|
||||||
|
|
||||||
|
export function shouldShowBadges(): boolean {
|
||||||
|
return (
|
||||||
|
isEnabled('desktop.showUserBadges') ||
|
||||||
|
isEnabled('desktop.internalUser') ||
|
||||||
|
getEnvironment() === Environment.Staging ||
|
||||||
|
getEnvironment() === Environment.Development ||
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
Boolean((window as any).STORYBOOK_ENV)
|
||||||
|
);
|
||||||
|
}
|
|
@ -24,6 +24,7 @@ import { shouldBlurAvatar } from '../util/shouldBlurAvatar';
|
||||||
import { getBadgeImageFileLocalPath } from '../badges/getBadgeImageFileLocalPath';
|
import { getBadgeImageFileLocalPath } from '../badges/getBadgeImageFileLocalPath';
|
||||||
import { isBadgeVisible } from '../badges/isBadgeVisible';
|
import { isBadgeVisible } from '../badges/isBadgeVisible';
|
||||||
import { BadgeImageTheme } from '../badges/BadgeImageTheme';
|
import { BadgeImageTheme } from '../badges/BadgeImageTheme';
|
||||||
|
import { shouldShowBadges } from '../badges/shouldShowBadges';
|
||||||
|
|
||||||
export enum AvatarBlur {
|
export enum AvatarBlur {
|
||||||
NoBlur,
|
NoBlur,
|
||||||
|
@ -213,7 +214,13 @@ export const Avatar: FunctionComponent<Props> = ({
|
||||||
}
|
}
|
||||||
|
|
||||||
let badgeNode: ReactNode;
|
let badgeNode: ReactNode;
|
||||||
if (badge && theme && !noteToSelf && isBadgeVisible(badge)) {
|
if (
|
||||||
|
badge &&
|
||||||
|
theme &&
|
||||||
|
!noteToSelf &&
|
||||||
|
isBadgeVisible(badge) &&
|
||||||
|
shouldShowBadges()
|
||||||
|
) {
|
||||||
const badgeSize = Math.ceil(size * 0.425);
|
const badgeSize = Math.ceil(size * 0.425);
|
||||||
const badgeTheme =
|
const badgeTheme =
|
||||||
theme === ThemeType.light ? BadgeImageTheme.Light : BadgeImageTheme.Dark;
|
theme === ThemeType.light ? BadgeImageTheme.Light : BadgeImageTheme.Dark;
|
||||||
|
|
|
@ -14,6 +14,7 @@ import { BadgeDialog } from '../BadgeDialog';
|
||||||
import type { BadgeType } from '../../badges/types';
|
import type { BadgeType } from '../../badges/types';
|
||||||
import { SharedGroupNames } from '../SharedGroupNames';
|
import { SharedGroupNames } from '../SharedGroupNames';
|
||||||
import { ConfirmationDialog } from '../ConfirmationDialog';
|
import { ConfirmationDialog } from '../ConfirmationDialog';
|
||||||
|
import { shouldShowBadges } from '../../badges/shouldShowBadges';
|
||||||
|
|
||||||
export type PropsDataType = {
|
export type PropsDataType = {
|
||||||
areWeAdmin: boolean;
|
areWeAdmin: boolean;
|
||||||
|
@ -105,7 +106,7 @@ export const ContactModal = ({
|
||||||
unblurredAvatarPath={contact.unblurredAvatarPath}
|
unblurredAvatarPath={contact.unblurredAvatarPath}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setView(
|
setView(
|
||||||
preferredBadge
|
preferredBadge && shouldShowBadges()
|
||||||
? ContactModalView.ShowingBadges
|
? ContactModalView.ShowingBadges
|
||||||
: ContactModalView.ShowingAvatar
|
: ContactModalView.ShowingAvatar
|
||||||
);
|
);
|
||||||
|
|
|
@ -15,6 +15,7 @@ import type { LocalizerType, ThemeType } from '../../../types/Util';
|
||||||
import { bemGenerator } from './util';
|
import { bemGenerator } from './util';
|
||||||
import { BadgeDialog } from '../../BadgeDialog';
|
import { BadgeDialog } from '../../BadgeDialog';
|
||||||
import type { BadgeType } from '../../../badges/types';
|
import type { BadgeType } from '../../../badges/types';
|
||||||
|
import { shouldShowBadges } from '../../../badges/shouldShowBadges';
|
||||||
|
|
||||||
export type Props = {
|
export type Props = {
|
||||||
badges?: ReadonlyArray<BadgeType>;
|
badges?: ReadonlyArray<BadgeType>;
|
||||||
|
@ -92,7 +93,7 @@ export const ConversationDetailsHeader: React.ComponentType<Props> = ({
|
||||||
noteToSelf={isMe}
|
noteToSelf={isMe}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setActiveModal(
|
setActiveModal(
|
||||||
preferredBadge
|
preferredBadge && shouldShowBadges()
|
||||||
? ConversationDetailsHeaderActiveModal.ShowingBadges
|
? ConversationDetailsHeaderActiveModal.ShowingBadges
|
||||||
: ConversationDetailsHeaderActiveModal.ShowingAvatar
|
: ConversationDetailsHeaderActiveModal.ShowingAvatar
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue