Skip to content

Commit baee6f8

Browse files
catch-21limpbrains
authored andcommitted
feat(ui): add Save Log button in debug settings for use in E2E tests
1 parent 3f97d11 commit baee6f8

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/screens/Settings/DevSettings/LdkDebug.tsx

+31
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import Share from 'react-native-share';
44
import { useTranslation } from 'react-i18next';
55
import Clipboard from '@react-native-clipboard/clipboard';
66
import lm from '@synonymdev/react-native-ldk';
7+
import RNFS from 'react-native-fs';
78

89
import { Caption13Up } from '../../../styles/text';
910
import { View as ThemedView, TextInput } from '../../../styles/components';
@@ -179,6 +180,30 @@ const LdkDebug = (): ReactElement => {
179180
});
180181
};
181182

183+
const onSaveLogs = async (): Promise<void> => {
184+
const result = await zipLogs();
185+
if (result.isErr()) {
186+
showToast({
187+
type: 'warning',
188+
title: t('error_logs'),
189+
description: t('error_logs_description'),
190+
});
191+
return;
192+
}
193+
194+
// Define the destination path in the Downloads folder
195+
const downloadsDir = RNFS.DownloadDirectoryPath;
196+
const destinationPath = `${downloadsDir}/bitkit_ldk_logs.zip`;
197+
198+
await RNFS.copyFile(result.value, destinationPath);
199+
200+
showToast({
201+
type: 'success',
202+
title: 'Logs saved', // todo: locale
203+
description: `${destinationPath}`,
204+
});
205+
};
206+
182207
const onCreateInvoice = async (amountSats = 100): Promise<void> => {
183208
const createPaymentRequest = await createLightningInvoice({
184209
amountSats,
@@ -371,6 +396,12 @@ const LdkDebug = (): ReactElement => {
371396
text="Export Logs"
372397
onPress={onExportLogs}
373398
/>
399+
<Button
400+
style={styles.button}
401+
text="Save Logs"
402+
onPress={onSaveLogs}
403+
testID="SaveLogs"
404+
/>
374405

375406
{openChannels.length > 0 && (
376407
<>

0 commit comments

Comments
 (0)