@@ -4,6 +4,7 @@ import Share from 'react-native-share';
4
4
import { useTranslation } from 'react-i18next' ;
5
5
import Clipboard from '@react-native-clipboard/clipboard' ;
6
6
import lm from '@synonymdev/react-native-ldk' ;
7
+ import RNFS from 'react-native-fs' ;
7
8
8
9
import { Caption13Up } from '../../../styles/text' ;
9
10
import { View as ThemedView , TextInput } from '../../../styles/components' ;
@@ -179,6 +180,30 @@ const LdkDebug = (): ReactElement => {
179
180
} ) ;
180
181
} ;
181
182
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
+
182
207
const onCreateInvoice = async ( amountSats = 100 ) : Promise < void > => {
183
208
const createPaymentRequest = await createLightningInvoice ( {
184
209
amountSats,
@@ -371,6 +396,12 @@ const LdkDebug = (): ReactElement => {
371
396
text = "Export Logs"
372
397
onPress = { onExportLogs }
373
398
/>
399
+ < Button
400
+ style = { styles . button }
401
+ text = "Save Logs"
402
+ onPress = { onSaveLogs }
403
+ testID = "SaveLogs"
404
+ />
374
405
375
406
{ openChannels . length > 0 && (
376
407
< >
0 commit comments