From 4426ed278b5386a3c53307dd28d0664b406abbdb Mon Sep 17 00:00:00 2001 From: hipitihop Date: Tue, 10 Mar 2015 15:57:26 +1000 Subject: [PATCH] undo - correct clear-history! to reset app-explain - fix subscription :undo-explanations to only con app-explain when there are undos --- src/re_frame/undo.cljs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/re_frame/undo.cljs b/src/re_frame/undo.cljs index 59a84f0..a02e708 100644 --- a/src/re_frame/undo.cljs +++ b/src/re_frame/undo.cljs @@ -36,7 +36,8 @@ (reset! undo-list []) (reset! redo-list []) (reset! undo-explain-list []) - (reset! redo-explain-list [])) + (reset! redo-explain-list []) + (reset! app-explain "")) (defn store-now! @@ -60,6 +61,13 @@ [] (pos? (count @redo-list))) +(defn undo-explanations + "return list of undo descriptions or empty list if no undos" + [] + (if (undos?) + (conj @undo-explain-list @app-explain) + [])) + ;; -- subscriptions ----------------------------------------------------------------------------- (subs/register @@ -82,7 +90,7 @@ (fn handler ; "return a vector of string explanations ordered oldest to most recent" [_ _] - (reaction (conj @undo-explain-list @app-explain)))) + (reaction (undo-explanations)))) (subs/register :redo-explanations