@@ -63,7 +63,7 @@ screenUpdate opts d j = \case
6363 BS sst -> BS $ bsUpdate opts d j sst
6464 IS sst -> IS $ isUpdate opts d j sst
6565 RS sst -> RS $ rsUpdate opts d j sst
66- TS sst -> TS $ tsUpdate sst
66+ TS sst -> TS $ tsUpdate opts d j sst
6767 ES sst -> ES $ esUpdate sst
6868
6969-- | Construct an error screen.
@@ -360,12 +360,17 @@ tsNew acct nts nt =
360360 ,_tssTransaction = nt
361361 }
362362
363- -- | Update a transaction screen.
364- -- This currently does nothing because the initialisation in rsHandle is not so easy to extract.
365- -- To see the updated transaction, one must exit and re-enter the transaction screen.
366- -- See also tsHandle.
367- tsUpdate :: TransactionScreenState -> TransactionScreenState
368- tsUpdate tss =
363+ -- | Update a transaction screen by refreshing the current transaction from the journal.
364+ -- This preserves the current transaction selection while updating its data.
365+ -- XXX Caveat, this works by showing the transaction at the same index in the processed ledger,
366+ -- if transactions have been inserted or removed before the one shown this will just show
367+ -- whatever transaction landed at the same index in the new data set.
368+ tsUpdate :: UIOpts -> Day -> Journal -> TransactionScreenState -> TransactionScreenState
369+ tsUpdate _ _ j tss@ TSS {_tssTransaction= (currentIdx,currentTxn)} =
369370 dbgui " tsUpdate" $
370- tss `seq` tss -- Force evaluation to prevent accumulation
371-
371+ let
372+ -- Find the updated version of the current transaction in the journal
373+ updatedTxn = case find (\ t -> tindex t == tindex currentTxn) (jtxns j) of
374+ Just t -> t
375+ Nothing -> currentTxn -- fallback to current if not found
376+ in tss { _tssTransaction = (currentIdx, updatedTxn) }
0 commit comments