fix:ui:transaction screen: update on data changes, second fix [#2288]

This one is more thorough and hopefully more robust.
Compared to the first fix, it fixes an error seen in --watch mode
when you save an error (and maybe then save a second edit,
and then repair the error - I forget)
This commit is contained in:
Simon Michael 2025-09-12 09:58:46 +01:00
parent e87d9e3ce3
commit e9c1fc36a3

View File

@ -142,11 +142,24 @@ tsHandle ev = do
-- g or file change: reload the journal. -- g or file change: reload the journal.
e | e `elem` [VtyEvent (EvKey (KChar 'g') []), AppEvent FileChange] -> do e | e `elem` [VtyEvent (EvKey (KChar 'g') []), AppEvent FileChange] -> do
-- To update all state: exit to register screen, regenerate screens, re-enter transaction screen. -- Update app state. This is tricky: (XXX anywhere else we need to be this thorough ?)
-- Anywhere else here that we need to be this thorough ?
uiReload copts d (popScreen ui) >>= put' -- Reload and regenerate screens
rsHandle (VtyEvent (EvKey KEnter [])) ui1 <- uiReload copts d ui
-- -- If that moved us to the error screen, save that and return to the transaction screen.
let
(merrscr, ui2) = case aScreen ui1 of
s@(ES _) -> (Just s, popScreen ui1)
_ -> (Nothing, ui1)
-- put' ui2
-- Now exit to register screen and make it regenerate the transaction screen,
-- for best initialisation.
put' $ popScreen ui2
rsHandle (VtyEvent (EvKey KEnter [])) -- XXX PARTIAL assumes we are on the register screen
-- Then re-enter the error screen if any, so error repair will return to the transaction screen.
let ui3 = maybe ui2 (`pushScreen` ui2) merrscr
put' ui3
-- for debugging; leaving these here because they were hard to find -- for debugging; leaving these here because they were hard to find
-- \u -> dbguiEv (pshow u) >> put' u -- doesn't log -- \u -> dbguiEv (pshow u) >> put' u -- doesn't log
-- \UIState{aScreen=TS tss} -> error' $ pshow $ _tssTransaction tss -- \UIState{aScreen=TS tss} -> error' $ pshow $ _tssTransaction tss