rvv001 - AddressBook completed - ready for tests
This commit is contained in:
parent
a33ae3b595
commit
edb7422951
3 changed files with 21 additions and 8 deletions
|
@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
## [0.5.2.0-beta]
|
||||
|
||||
### Added
|
||||
|
||||
- Address Book functionality. Allows users to store frequently used zcash addresses and
|
||||
generate transactions using them.
|
||||
|
||||
### Changed
|
||||
|
||||
- Update to `zcash-haskell-0.6.2.0` to increase performance of transaction creation
|
||||
|
|
|
@ -414,7 +414,7 @@ drawUI s = [splashDialog s, helpDialog s, displayDialog s, inputDialog s, ui s]
|
|||
(D.dialog (Just $ str " Delete Address Book Entry ") Nothing 50)
|
||||
(renderForm (st ^. abForm) <=>
|
||||
C.hCenter
|
||||
(hBox [capCommand "↲" " Delete", capCommand3 "" "<Esc>" " Cancel"]))
|
||||
(hBox [capCommand "C" "onfirm delete", capCommand3 "" "<Esc>" " Cancel"]))
|
||||
--
|
||||
|
||||
splashDialog :: State -> Widget Name
|
||||
|
@ -1179,8 +1179,15 @@ appEvent (BT.VtyEvent e) = do
|
|||
AdrBookDelForm -> do
|
||||
case e of
|
||||
V.EvKey V.KEsc [] -> BT.modify $ set dialogBox AdrBook
|
||||
V.EvKey V.KEnter [] -> BT.modify $ set dialogBox AdrBook
|
||||
V.EvKey (V.KChar 'c') [] -> do
|
||||
pool <- liftIO $ runNoLoggingT $ initPool $ s ^. dbPath
|
||||
fs <- BT.zoom abForm $ BT.gets formState
|
||||
res <- liftIO $ deleteAdrsFromAB pool (fs ^.address)
|
||||
s' <- liftIO $ refreshAddressBook s
|
||||
BT.put s'
|
||||
BT.modify $ set dialogBox AdrBook
|
||||
ev -> BT.modify $ set dialogBox AdrBookDelForm
|
||||
-- Process any other event
|
||||
Blank -> do
|
||||
case e of
|
||||
V.EvKey (V.KChar '\t') [] -> focusRing %= F.focusNext
|
||||
|
|
|
@ -1504,6 +1504,7 @@ updateAdrsInAdrBook pool d a ia = do
|
|||
set ab [AddressBookDescrip =. val d, AddressBookAddress =. val a]
|
||||
where_ $ ab ^. AddressBookAddress ==. val ia
|
||||
|
||||
-- | Get one AddrssBook record using the Address as a key
|
||||
getABookRec :: ConnectionPool -> T.Text -> IO [Entity AddressBook]
|
||||
getABookRec pool a = do
|
||||
runNoLoggingT $
|
||||
|
@ -1515,14 +1516,14 @@ getABookRec pool a = do
|
|||
return adrbook
|
||||
|
||||
-- | delete an existing address from AddressBook
|
||||
deleteAdrsFromAB :: ConnectionPool -> AddressBookId -> IO ()
|
||||
deleteAdrsFromAB pool i = do
|
||||
deleteAdrsFromAB :: ConnectionPool -> T.Text -> IO ()
|
||||
deleteAdrsFromAB pool ia = do
|
||||
runNoLoggingT $
|
||||
PS.retryOnBusy $
|
||||
flip PS.runSqlPool pool $ do
|
||||
delete $ do
|
||||
ab <- from $ table @AddressBook
|
||||
where_ (ab ^. AddressBookId ==. val i)
|
||||
where_ (ab ^. AddressBookAddress ==. val ia)
|
||||
|
||||
rmdups :: Ord a => [a] -> [a]
|
||||
rmdups = map head . group . sort
|
||||
|
|
Loading…
Reference in a new issue