Enable media editor for everyone

This commit is contained in:
Evan Hahn 2021-12-14 18:53:15 -06:00 committed by GitHub
parent 71e9498961
commit 97d42d5e7b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 3 additions and 29 deletions

View file

@ -58,7 +58,6 @@ import {
import { MediaEditor } from './MediaEditor'; import { MediaEditor } from './MediaEditor';
import { IMAGE_PNG } from '../types/MIME'; import { IMAGE_PNG } from '../types/MIME';
import { isImageTypeSupported } from '../util/GoogleChrome'; import { isImageTypeSupported } from '../util/GoogleChrome';
import { canEditImages } from '../util/canEditImages';
export type CompositionAPIType = export type CompositionAPIType =
| { | {
@ -293,13 +292,8 @@ export const CompositionArea = ({
} }
}, []); }, []);
const hasImageEditingEnabled = canEditImages();
function maybeEditAttachment(attachment: AttachmentDraftType) { function maybeEditAttachment(attachment: AttachmentDraftType) {
if ( if (!isImageTypeSupported(attachment.contentType)) {
!hasImageEditingEnabled ||
!isImageTypeSupported(attachment.contentType)
) {
return; return;
} }
@ -647,7 +641,6 @@ export const CompositionArea = ({
<div className="CompositionArea__attachment-list"> <div className="CompositionArea__attachment-list">
<AttachmentList <AttachmentList
attachments={draftAttachments} attachments={draftAttachments}
canEditImages={hasImageEditingEnabled}
i18n={i18n} i18n={i18n}
onAddAttachment={launchAttachmentPicker} onAddAttachment={launchAttachmentPicker}
onClickAttachment={maybeEditAttachment} onClickAttachment={maybeEditAttachment}

View file

@ -46,7 +46,7 @@ story.add('One File', () => {
}), }),
], ],
}); });
return <AttachmentList {...props} canEditImages />; return <AttachmentList {...props} />;
}); });
story.add('Multiple Visual Attachments', () => { story.add('Multiple Visual Attachments', () => {

View file

@ -20,7 +20,6 @@ import {
export type Props<T extends AttachmentType | AttachmentDraftType> = Readonly<{ export type Props<T extends AttachmentType | AttachmentDraftType> = Readonly<{
attachments: ReadonlyArray<T>; attachments: ReadonlyArray<T>;
canEditImages?: boolean;
i18n: LocalizerType; i18n: LocalizerType;
onAddAttachment?: () => void; onAddAttachment?: () => void;
onClickAttachment?: (attachment: T) => void; onClickAttachment?: (attachment: T) => void;
@ -51,7 +50,6 @@ function getUrl(
export const AttachmentList = <T extends AttachmentType | AttachmentDraftType>({ export const AttachmentList = <T extends AttachmentType | AttachmentDraftType>({
attachments, attachments,
canEditImages,
i18n, i18n,
onAddAttachment, onAddAttachment,
onClickAttachment, onClickAttachment,
@ -121,7 +119,7 @@ export const AttachmentList = <T extends AttachmentType | AttachmentDraftType>({
/> />
); );
if (isImage && canEditImages) { if (isImage) {
return ( return (
<div className="module-attachments--editable"> <div className="module-attachments--editable">
{imgElement} {imgElement}

View file

@ -1,17 +0,0 @@
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { isEnabled } from '../RemoteConfig';
import { getEnvironment, Environment } from '../environment';
import { isBeta } from './version';
export function canEditImages(): boolean {
return (
isEnabled('desktop.internalUser') ||
getEnvironment() === Environment.Staging ||
getEnvironment() === Environment.Development ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Boolean((window as any).STORYBOOK_ENV) ||
isBeta(window.getVersion())
);
}