Fix export chat android (#324)

* Fix export chat button on Android

* Fix export chat button on Android
This commit is contained in:
KoalaSat 2022-11-17 17:29:56 +00:00 committed by GitHub
parent 9d80ca6fdb
commit 7c3293775b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,6 +4,7 @@ import { ExportIcon } from '../../../Icons';
import KeyIcon from '@mui/icons-material/Key';
import { useTranslation } from 'react-i18next';
import { saveAsJson } from '../../../../utils';
import { systemClient } from '../../../../services/System';
interface Props {
orderId: number;
@ -16,6 +17,14 @@ const ChatBottom: React.FC<Props> = ({ orderId, setAudit, audit, createJsonFile
const { t } = useTranslation();
const theme = useTheme();
const onPGPClick: () => void = () => {
if (window.ReactNativeWebView === undefined) {
saveAsJson('complete_log_chat_' + orderId + '.json', createJsonFile());
} else {
systemClient.copyToClipboard(JSON.stringify(createJsonFile()));
}
};
return (
<>
<Grid item xs={6}>
@ -41,12 +50,7 @@ const ChatBottom: React.FC<Props> = ({ orderId, setAudit, audit, createJsonFile
enterNextDelay={2000}
title={t('Save full log as a JSON file (messages and credentials)')}
>
<Button
size='small'
color='primary'
variant='outlined'
onClick={() => saveAsJson('complete_log_chat_' + orderId + '.json', createJsonFile())}
>
<Button size='small' color='primary' variant='outlined' onClick={onPGPClick}>
<div style={{ width: '1.4em', height: '1.4em' }}>
<ExportIcon sx={{ width: '0.8em', height: '0.8em' }} />
</div>{' '}