@@ -4,6 +4,7 @@ import Share from 'react-native-share';
44import { useTranslation } from 'react-i18next' ;
55import Clipboard from '@react-native-clipboard/clipboard' ;
66import lm from '@synonymdev/react-native-ldk' ;
7+ import RNFS from 'react-native-fs' ;
78
89import { Caption13Up } from '../../../styles/text' ;
910import { 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