rvv041 - Code Optimizations

addressbook's column descrip renamed to abdescrip
	 _abText - variable used to hold AddressBook entry data for display
	 _abCurAdrs - variable used to hold unique key in CRUD operations
This commit is contained in:
Rene V. Vergara A. 2024-06-03 14:28:39 -04:00
parent 51116e8083
commit d57ac5db14
1 changed files with 15 additions and 15 deletions

View File

@ -192,10 +192,10 @@ data State = State
, _eventDispatch :: !(BC.BChan Tick)
, _timer :: !Int
, _txForm :: !(Form SendInput () Name)
, _abaddresses :: !(L.List Name (Entity AddressBook))
, _abAddresses :: !(L.List Name (Entity AddressBook))
, _abForm :: !(Form AdrBookEntry () Name)
, _abCurAdrs :: !T.Text
, _abTxt :: !T.Text
, _abCurAdrs :: !T.Text -- used for address book CRUD operations
, _abTxt :: !T.Text -- Holds the Address Book entry data to show
}
makeLenses ''State
@ -379,7 +379,7 @@ drawUI s = [splashDialog s, helpDialog s, displayDialog s, inputDialog s, ui s]
hLimit 50 $
vBox [vLimit 16 $
hLimit 50 $
vBox $ [ L.renderList listDrawAB True (s ^. abaddresses) ],
vBox $ [ L.renderList listDrawAB True (s ^. abAddresses) ],
padTop Max $
vLimit 4 $
hLimit 50 $
@ -1046,7 +1046,7 @@ appEvent (BT.VtyEvent e) = do
BT.modify $ set dialogBox Blank
V.EvKey (V.KChar 'c') [] -> do
-- Copy Address to Clipboard
case L.listSelectedElement $ s ^. abaddresses of
case L.listSelectedElement $ s ^. abAddresses of
Just (_, a) -> do
liftIO $
setClipboard $
@ -1062,7 +1062,7 @@ appEvent (BT.VtyEvent e) = do
BT.modify $ set displayBox MsgDisplay
-- Send Zcash transaction
V.EvKey (V.KChar 's') [] -> do
case L.listSelectedElement $ s ^. abaddresses of
case L.listSelectedElement $ s ^. abAddresses of
Just (_, a) -> do
BT.modify $
set txForm $
@ -1073,7 +1073,7 @@ appEvent (BT.VtyEvent e) = do
BT.modify $ set displayBox MsgDisplay
-- Edit an entry in Address Book
V.EvKey (V.KChar 'e') [] -> do
case L.listSelectedElement $ s ^. abaddresses of
case L.listSelectedElement $ s ^. abAddresses of
Just (_, a) -> do
BT.modify $ set abCurAdrs (addressBookAbaddress (entityVal a))
BT.modify $
@ -1084,7 +1084,7 @@ appEvent (BT.VtyEvent e) = do
BT.modify $ set dialogBox Blank
-- Delete an entry from Address Book
V.EvKey (V.KChar 'd') [] -> do
case L.listSelectedElement $ s ^. abaddresses of
case L.listSelectedElement $ s ^. abAddresses of
Just (_, a) -> do
BT.modify $ set abCurAdrs (addressBookAbaddress (entityVal a))
BT.modify $
@ -1099,7 +1099,7 @@ appEvent (BT.VtyEvent e) = do
BT.modify $ set dialogBox AdrBookForm
-- Show AddressBook entry data
V.EvKey V.KEnter [] -> do
case L.listSelectedElement $ s ^. abaddresses of
case L.listSelectedElement $ s ^. abAddresses of
Just (_, a) -> do
BT.modify $ set abTxt $ T.pack $
" Descr: " ++
@ -1110,7 +1110,7 @@ appEvent (BT.VtyEvent e) = do
_ -> do
BT.modify $ set dialogBox Blank
-- Process any other event
ev -> BT.zoom abaddresses $ L.handleListEvent ev
ev -> BT.zoom abAddresses $ L.handleListEvent ev
-- Process new address book entry
AdrBookForm -> do
case e of
@ -1218,7 +1218,7 @@ appEvent (BT.VtyEvent e) = do
Just TList ->
BT.zoom transactions $ L.handleListEvent ev
Just ABList ->
BT.zoom abaddresses $ L.handleListEvent ev
BT.zoom abAddresses $ L.handleListEvent ev
_anyName -> return ()
where
printMsg :: String -> BT.EventM Name State ()
@ -1485,18 +1485,18 @@ refreshAddressBook :: State -> IO State
refreshAddressBook s = do
pool <- runNoLoggingT $ initPool $ s ^. dbPath
selAddress <-
do case L.listSelectedElement $ s ^. abaddresses of
do case L.listSelectedElement $ s ^. abAddresses of
Nothing -> do
let fAdd =
L.listSelectedElement $ L.listMoveToBeginning $ s ^. abaddresses
L.listSelectedElement $ L.listMoveToBeginning $ s ^. abAddresses
return fAdd
Just a2 -> return $ Just a2
case selAddress of
Nothing -> return s
Just (_i, a) -> do
abookList <- getAdrBook pool (s ^. network)
let tL' = L.listReplace (Vec.fromList abookList) (Just 0) (s ^. abaddresses)
return $ s & abaddresses .~ tL'
let tL' = L.listReplace (Vec.fromList abookList) (Just 0) (s ^. abAddresses)
return $ s & abAddresses .~ tL'
addNewAddress :: T.Text -> Scope -> State -> IO State
addNewAddress n scope s = do