fix(helpers) move copyText function to web.js file

It gets bundled on mobile for no reason otherwise.
This commit is contained in:
Filip Rejmus 2022-09-26 19:31:06 +02:00 committed by GitHub
parent c613082ce1
commit c3ebde18df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 20 deletions

View File

@ -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 {

View File

@ -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<boolean>}
*/
export async function copyText(textToCopy: string) {
try {
await clipboardCopy(textToCopy);
return true;
} catch (e) {
return false;
}
}

View File

@ -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<boolean>}
*/
export async function copyText(textToCopy: string) {
try {
await clipboardCopy(textToCopy);
return true;
} catch (e) {
return false;
}
}
/**
* Creates a deferred object.

View File

@ -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';