Skip to content

Commit

Permalink
Merge pull request #43938 from jayeshmangwani/revert_client_side_logging
Browse files Browse the repository at this point in the history
reverted the ClientSideLoggingToolMenu Android iOS files
  • Loading branch information
yuwenmemon authored Jun 18, 2024
2 parents c1c0bbd + 96b5754 commit 04e1e18
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 12 deletions.
49 changes: 43 additions & 6 deletions src/components/ClientSideLoggingToolMenu/index.android.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,47 @@
/**
* Since client-side logging is currently supported on web and desktop natively right now,
* this menu will be hidden in iOS and Android.
* See comment here: https://github.com/Expensify/App/issues/43256#issuecomment-2154610196
*/
import React, {useState} from 'react';
import RNFetchBlob from 'react-native-blob-util';
import Share from 'react-native-share';
import type {Log} from '@libs/Console';
import localFileCreate from '@libs/localFileCreate';
import CONST from '@src/CONST';
import BaseClientSideLoggingToolMenu from './BaseClientSideLoggingToolMenu';

function ClientSideLoggingToolMenu() {
return null;
const [file, setFile] = useState<{path: string; newFileName: string; size: number}>();

const createAndSaveFile = (logs: Log[]) => {
localFileCreate('logs', JSON.stringify(logs, null, 2)).then((localFile) => {
RNFetchBlob.MediaCollection.copyToMediaStore(
{
name: localFile.newFileName,
parentFolder: '',
mimeType: 'text/plain',
},
'Download',
localFile.path,
);
setFile(localFile);
});
};

const shareLogs = () => {
if (!file) {
return;
}
Share.open({
url: `file://${file.path}`,
});
};

return (
<BaseClientSideLoggingToolMenu
file={file}
onEnableLogging={() => setFile(undefined)}
onDisableLogging={createAndSaveFile}
onShareLogs={shareLogs}
displayPath={`${CONST.DOWNLOADS_PATH}/${file?.newFileName ?? ''}`}
/>
);
}

ClientSideLoggingToolMenu.displayName = 'ClientSideLoggingToolMenu';
Expand Down
42 changes: 36 additions & 6 deletions src/components/ClientSideLoggingToolMenu/index.ios.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,40 @@
/**
* Since client-side logging is currently supported on web and desktop natively right now,
* this menu will be hidden in iOS and Android.
* See comment here: https://github.com/Expensify/App/issues/43256#issuecomment-2154610196
*/
import React, {useState} from 'react';
import Share from 'react-native-share';
import useEnvironment from '@hooks/useEnvironment';
import type {Log} from '@libs/Console';
import getDownloadFolderPathSuffixForIOS from '@libs/getDownloadFolderPathSuffixForIOS';
import localFileCreate from '@libs/localFileCreate';
import CONST from '@src/CONST';
import BaseClientSideLoggingToolMenu from './BaseClientSideLoggingToolMenu';

function ClientSideLoggingToolMenu() {
return null;
const [file, setFile] = useState<{path: string; newFileName: string; size: number}>();
const {environment} = useEnvironment();

const createFile = (logs: Log[]) => {
localFileCreate('logs', JSON.stringify(logs, null, 2)).then((localFile) => {
setFile(localFile);
});
};

const shareLogs = () => {
if (!file) {
return;
}
Share.open({
url: `file://${file.path}`,
});
};

return (
<BaseClientSideLoggingToolMenu
file={file}
onEnableLogging={() => setFile(undefined)}
onDisableLogging={createFile}
onShareLogs={shareLogs}
displayPath={`${CONST.NEW_EXPENSIFY_PATH}${getDownloadFolderPathSuffixForIOS(environment)}/${file?.newFileName ?? ''}`}
/>
);
}

ClientSideLoggingToolMenu.displayName = 'ClientSideLoggingToolMenu';
Expand Down

0 comments on commit 04e1e18

Please sign in to comment.