fix(helpers) move copyText function to web.js file
It gets bundled on mobile for no reason otherwise.
This commit is contained in:
parent
c613082ce1
commit
c3ebde18df
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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.
|
||||
|
|
|
@ -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';
|
||||
|
|
Loading…
Reference in New Issue