fix(rn,util) avoid 'clipboard-copy' being bundled in native

The copyText wrapper is used in the `showStartedRecordingNotification`
action, which is common for web and native. Provide a native
implementation so the right one is bundled.
This commit is contained in:
Saúl Ibarra Corretgé 2022-10-06 10:11:06 +02:00 committed by Saúl Ibarra Corretgé
parent d2a36ea3a8
commit a2d39ca5b1
8 changed files with 25 additions and 7 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/copyText';
import { copyText } from '../util/copyText.web';
const styles = (theme: Theme) => {
return {

View File

@ -0,0 +1,18 @@
import Clipboard from '@react-native-community/clipboard';
/**
* 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 function copyText(textToCopy: string) {
try {
Clipboard.setString(textToCopy);
return true;
} catch (e) {
return false;
}
}

View File

@ -4,7 +4,7 @@ import React, { Component } from 'react';
import { translate } from '../../../../base/i18n';
import { Icon, IconCopy } from '../../../../base/icons';
import { copyText } from '../../../../base/util/copyText';
import { copyText } from '../../../../base/util/copyText.web';
import { _formatConferenceIDPin } from '../../../_utils';
/**

View File

@ -16,7 +16,7 @@ import {
IconYahoo
} from '../../../../base/icons';
import { Tooltip } from '../../../../base/tooltip';
import { copyText } from '../../../../base/util/copyText';
import { copyText } from '../../../../base/util/copyText.web';
type Props = {

View File

@ -6,7 +6,7 @@ import React, { useState } from 'react';
import { translate } from '../../../../base/i18n';
import { Icon, IconCheck, IconCopy } from '../../../../base/icons';
import { copyText } from '../../../../base/util/copyText';
import { copyText } from '../../../../base/util/copyText.web';
type Props = {

View File

@ -1,4 +1,3 @@
import Clipboard from '@react-native-community/clipboard';
import React, { PureComponent } from 'react';
import {
Text,
@ -16,6 +15,7 @@ import Button from '../../../../base/ui/components/native/Button';
import Input from '../../../../base/ui/components/native/Input';
import Switch from '../../../../base/ui/components/native/Switch';
import { BUTTON_TYPES } from '../../../../base/ui/constants';
import { copyText } from '../../../../base/util/copyText.native';
import { isInBreakoutRoom } from '../../../../breakout-rooms/functions';
import { toggleLobbyMode } from '../../../../lobby/actions.any';
import { LOCKED_LOCALLY, LOCKED_REMOTELY } from '../../../../room-lock';
@ -475,7 +475,7 @@ class SecurityDialog extends PureComponent<Props, State> {
_onCopy() {
const { passwordInputValue } = this.state;
Clipboard.setString(passwordInputValue);
copyText(passwordInputValue);
}
_onSubmit: () => void;

View File

@ -3,7 +3,7 @@ import React, { useRef, useState } from 'react';
import { WithTranslation } from 'react-i18next';
import { translate } from '../../../../base/i18n/functions';
import { copyText } from '../../../../base/util/copyText';
import { copyText } from '../../../../base/util/copyText.web';
import { LOCKED_LOCALLY } from '../../../../room-lock/constants';
import { NOTIFY_CLICK_MODE } from '../../../../toolbox/constants';