From c3ebde18df3d8a6aa0f4dfad45ec4eb4dbbc648d Mon Sep 17 00:00:00 2001 From: Filip Rejmus Date: Mon, 26 Sep 2022 19:31:06 +0200 Subject: [PATCH] fix(helpers) move copyText function to web.js file It gets bundled on mobile for no reason otherwise. --- react/features/base/buttons/CopyButton.tsx | 2 +- react/features/base/util/copyText.ts | 18 ++++++++++++++++++ react/features/base/util/helpers.ts | 18 ------------------ .../security-dialog/web/PasswordSection.tsx | 2 +- 4 files changed, 20 insertions(+), 20 deletions(-) create mode 100644 react/features/base/util/copyText.ts diff --git a/react/features/base/buttons/CopyButton.tsx b/react/features/base/buttons/CopyButton.tsx index 33271ea39d..6614d8c5c2 100644 --- a/react/features/base/buttons/CopyButton.tsx +++ b/react/features/base/buttons/CopyButton.tsx @@ -7,7 +7,7 @@ import React, { useEffect, useState } from 'react'; import Icon from '../icons/components/Icon'; import { IconCheck, IconCopy } from '../icons/svg'; import { withPixelLineHeight } from '../styles/functions.web'; -import { copyText } from '../util/helpers'; +import { copyText } from '../util/copyText'; const styles = (theme: Theme) => { return { diff --git a/react/features/base/util/copyText.ts b/react/features/base/util/copyText.ts new file mode 100644 index 0000000000..46f1dfeb7d --- /dev/null +++ b/react/features/base/util/copyText.ts @@ -0,0 +1,18 @@ +import clipboardCopy from 'clipboard-copy'; + +/** + * Tries to copy a given text to the clipboard. + * Returns true if the action succeeds. + * + * @param {string} textToCopy - Text to be copied. + * @returns {Promise} + */ +export async function copyText(textToCopy: string) { + try { + await clipboardCopy(textToCopy); + + return true; + } catch (e) { + return false; + } +} diff --git a/react/features/base/util/helpers.ts b/react/features/base/util/helpers.ts index f2455023ef..ba693efa4c 100644 --- a/react/features/base/util/helpers.ts +++ b/react/features/base/util/helpers.ts @@ -1,5 +1,3 @@ -import clipboardCopy from 'clipboard-copy'; - /** * A helper function that behaves similar to Object.assign, but only reassigns a * property in target if it's defined in source. @@ -24,22 +22,6 @@ export function assignIfDefined(target: Object, source: Object) { return to; } -/** - * Tries to copy a given text to the clipboard. - * Returns true if the action succeeds. - * - * @param {string} textToCopy - Text to be copied. - * @returns {Promise} - */ -export async function copyText(textToCopy: string) { - try { - await clipboardCopy(textToCopy); - - return true; - } catch (e) { - return false; - } -} /** * Creates a deferred object. diff --git a/react/features/security/components/security-dialog/web/PasswordSection.tsx b/react/features/security/components/security-dialog/web/PasswordSection.tsx index f60ebd9395..420332cb12 100644 --- a/react/features/security/components/security-dialog/web/PasswordSection.tsx +++ b/react/features/security/components/security-dialog/web/PasswordSection.tsx @@ -3,7 +3,7 @@ import React, { useRef } from 'react'; import { WithTranslation } from 'react-i18next'; import { translate } from '../../../../base/i18n/functions'; -import { copyText } from '../../../../base/util/helpers'; +import { copyText } from '../../../../base/util/copyText'; import { NOTIFY_CLICK_MODE } from '../../../../toolbox/constants'; import PasswordForm from './PasswordForm';