11import { MutinyWallet } from "@mutinywallet/mutiny-wasm" ;
22import { createSignal , Show } from "solid-js" ;
33
4- import {
5- Button ,
6- InfoBox ,
7- InnerCard ,
8- NiceP ,
9- SimpleDialog ,
10- TextField ,
11- VStack
12- } from "~/components" ;
4+ import { Button , InfoBox , InnerCard , NiceP , VStack } from "~/components" ;
135import { useI18n } from "~/i18n/context" ;
146import { downloadTextFile , eify } from "~/utils" ;
157
@@ -18,40 +10,22 @@ export function Logs() {
1810
1911 // Create state for errors, password and dialog visibility
2012 const [ error , setError ] = createSignal < Error > ( ) ;
21- const [ exportDecrypt , setExportDecrypt ] = createSignal ( false ) ;
22- const [ password , setPassword ] = createSignal < string > ( ) ;
2313
2414 async function handleSave ( ) {
2515 try {
2616 setError ( undefined ) ;
27- const logs = await MutinyWallet . get_logs ( password ( ) ) ; // Use password if required
17+ const logs = await MutinyWallet . get_logs ( ) ;
2818 await downloadTextFile (
2919 logs . join ( "" ) || "" ,
3020 "mutiny-logs.txt" ,
3121 "text/plain"
3222 ) ;
3323 } catch ( e ) {
3424 console . error ( e ) ;
35- const err = eify ( e ) ;
36- if ( err . message === "Incorrect password entered." ) {
37- setExportDecrypt ( true ) ;
38- } else {
39- setError ( err ) ;
40- }
25+ setError ( eify ( e ) ) ;
4126 }
4227 }
4328
44- function savePassword ( e : Event ) {
45- e . preventDefault ( ) ;
46- handleSave ( ) ;
47- setPassword ( undefined ) ; // clear password after use
48- setExportDecrypt ( false ) ; // close the dialog
49- }
50-
51- function noop ( ) {
52- // noop
53- }
54-
5529 return (
5630 < InnerCard title = { i18n . t ( "settings.emergency_kit.logs.title" ) } >
5731 < VStack >
@@ -65,33 +39,6 @@ export function Logs() {
6539 < Show when = { error ( ) } >
6640 < InfoBox accent = "red" > { error ( ) ?. message } </ InfoBox >
6741 </ Show >
68- < SimpleDialog
69- title = { i18n . t ( "settings.emergency_kit.logs.password" ) }
70- open = { exportDecrypt ( ) }
71- >
72- < form onSubmit = { savePassword } >
73- < div class = "flex flex-col gap-4" >
74- < TextField
75- name = "password"
76- type = "password"
77- ref = { noop }
78- value = { password ( ) }
79- onInput = { ( e ) => setPassword ( e . currentTarget . value ) }
80- error = { "" }
81- onBlur = { noop }
82- onChange = { noop }
83- />
84- < Show when = { error ( ) } >
85- < InfoBox accent = "red" > { error ( ) ?. message } </ InfoBox >
86- </ Show >
87- < Button intent = "blue" onClick = { savePassword } >
88- { i18n . t (
89- "settings.emergency_kit.logs.confirm_password_label"
90- ) }
91- </ Button >
92- </ div >
93- </ form >
94- </ SimpleDialog >
9542 </ InnerCard >
9643 ) ;
9744}
0 commit comments