rvv041 - Code Optimization

- abText state variable removed
	 - AdrBookEntryDisplay refactored to use abAddresses state variable
This commit is contained in:
Rene V. Vergara A. 2024-06-03 21:41:48 -04:00
parent c5b7714917
commit 4f0fa9bc34
1 changed files with 19 additions and 19 deletions

View File

@ -195,7 +195,6 @@ data State = State
, _abAddresses :: !(L.List Name (Entity AddressBook)) , _abAddresses :: !(L.List Name (Entity AddressBook))
, _abForm :: !(Form AdrBookEntry () Name) , _abForm :: !(Form AdrBookEntry () Name)
, _abCurAdrs :: !T.Text -- used for address book CRUD operations , _abCurAdrs :: !T.Text -- used for address book CRUD operations
, _abTxt :: !T.Text -- Holds the Address Book entry data to show
} }
makeLenses ''State makeLenses ''State
@ -549,14 +548,21 @@ drawUI s = [splashDialog s, helpDialog s, displayDialog s, inputDialog s, ui s]
(strWrapWith (strWrapWith
(WrapSettings False True NoFill FillAfterFirst) (WrapSettings False True NoFill FillAfterFirst)
(st ^. msg))) (st ^. msg)))
AdrBookEntryDisplay -> AdrBookEntryDisplay -> do
withBorderStyle unicodeBold $ case L.listSelectedElement $ st ^. abAddresses of
D.renderDialog Just (_, a) -> do
(D.dialog (Just $ txt " Address Book Entry ") Nothing 60) let abentry = T.pack $
(padAll 1 $ " Descr: " ++
txtWrapWith (WrapSettings False True NoFill FillAfterFirst) $ T.unpack (addressBookAbdescrip (entityVal a)) ++
(st ^. abTxt)) "\n Address: " ++
T.unpack (addressBookAbaddress (entityVal a))
withBorderStyle unicodeBold $
D.renderDialog
(D.dialog (Just $ txt " Address Book Entry ") Nothing 60)
(padAll 1 $
txtWrapWith (WrapSettings False True NoFill FillAfterFirst) $
abentry)
_ -> emptyWidget
BlankDisplay -> emptyWidget BlankDisplay -> emptyWidget
mkInputForm :: DialogInput -> Form DialogInput e Name mkInputForm :: DialogInput -> Form DialogInput e Name
@ -1099,16 +1105,11 @@ appEvent (BT.VtyEvent e) = do
BT.modify $ set dialogBox AdrBookForm BT.modify $ set dialogBox AdrBookForm
-- Show AddressBook entry data -- Show AddressBook entry data
V.EvKey V.KEnter [] -> do V.EvKey V.KEnter [] -> do
case L.listSelectedElement $ s ^. abAddresses of -- case L.listSelectedElement $ s ^. abAddresses of
Just (_, a) -> do -- Just (_, a) -> do
BT.modify $ set abTxt $ T.pack $
" Descr: " ++
T.unpack (addressBookAbdescrip (entityVal a)) ++
"\n Address: " ++
T.unpack (addressBookAbaddress (entityVal a))
BT.modify $ set displayBox AdrBookEntryDisplay BT.modify $ set displayBox AdrBookEntryDisplay
_ -> do -- _ -> do
BT.modify $ set dialogBox Blank --q BT.modify $ set dialogBox Blank
-- Process any other event -- Process any other event
ev -> BT.zoom abAddresses $ L.handleListEvent ev ev -> BT.zoom abAddresses $ L.handleListEvent ev
-- Process new address book entry -- Process new address book entry
@ -1336,7 +1337,6 @@ runZenithCLI config = do
(mkSendForm 0 $ SendInput "" 0.0 "") (mkSendForm 0 $ SendInput "" 0.0 "")
(L.list ABList (Vec.fromList abookList) 1) (L.list ABList (Vec.fromList abookList) 1)
(mkNewABForm (AdrBookEntry "" "")) (mkNewABForm (AdrBookEntry "" ""))
" "
"" ""
Left e -> print $ Left e -> print $
"No Zebra node available on port " <> "No Zebra node available on port " <>