fix: ui: fix state bugs from brick 1 migration (#1889)

This commit is contained in:
Simon Michael 2022-08-22 23:58:29 +01:00
parent 67cd6be424
commit b6353804b8
3 changed files with 16 additions and 14 deletions

View File

@ -371,21 +371,24 @@ asHandle ev = do
list' <- nestEventM' _asList $ handleListEvent (normaliseMovementKeys ev)
put' $ ui{aScreen=scr & asList .~ list' & asSelectedAccount .~ selacct }
MouseDown{} -> put ui
MouseUp{} -> put ui
AppEvent _ -> put ui
MouseDown{} -> return ()
MouseUp{} -> return ()
AppEvent _ -> return ()
_ -> dlogUiTraceM "asHandle 2" >> errorWrongScreenType "event handler"
asEnterRegister :: Day -> AccountName -> UIState -> EventM Name UIState ()
asEnterRegister d selacct ui = do
rsCenterAndContinue $
-- flip rsHandle (VtyEvent (EvKey (KChar 'l') [MCtrl])) $
screenEnter d regscr ui
dlogUiTraceM "asEnterRegister"
let
regscr = rsSetAccount selacct isdepthclipped registerScreen
where
regscr = rsSetAccount selacct isdepthclipped registerScreen
isdepthclipped = case getDepth ui of
Just d -> accountNameLevel selacct >= d
Nothing -> False
Just d -> accountNameLevel selacct >= d
Nothing -> False
let ui' = screenEnter d regscr ui
put' ui'
rsCenterSelection ui'
asSetSelectedAccount a s@AccountsScreen{} = s & asSelectedAccount .~ a
asSetSelectedAccount _ s = s

View File

@ -166,8 +166,8 @@ runBrickUi uopts@UIOpts{uoCliOpts=copts@CliOpts{inputopts_=_iopts,reportspec_=rs
appStartEvent = return ()
, appAttrMap = const $ fromMaybe defaultTheme $ getTheme =<< uoTheme uopts'
, appChooseCursor = showFirstCursor
, appHandleEvent = sHandle (aScreen ui)
, appDraw = sDraw (aScreen ui)
, appHandleEvent = \ev -> do ui <- get; sHandle (aScreen ui) ev
, appDraw = \ui -> sDraw (aScreen ui) ui
}
-- print (length (show ui)) >> exitSuccess -- show any debug output to this point & quit

View File

@ -425,8 +425,7 @@ rsHandle ev = do
isBlankElement mel = ((rsItemDate . snd) <$> mel) == Just ""
rsCenterAndContinue ui = do
scrollSelectionToMiddle $ rsList $ aScreen ui
put ui
rsCenterSelection :: UIState -> EventM Name UIState ()
rsCenterSelection = scrollSelectionToMiddle . rsList . aScreen
rsListSize = V.length . V.takeWhile ((/="").rsItemDate) . listElements