diff options
author | Sébastien Dailly <sebastien@chimrod.com> | 2021-04-29 15:37:24 +0200 |
---|---|---|
committer | Sébastien Dailly <sebastien@dailly.me> | 2022-02-07 16:43:33 +0100 |
commit | 4d35508a76676a548ac45e0bff2d63eafaf014e2 (patch) | |
tree | 7668ef4cc0a04391edb9a1f3a921b1f917d765bd /editor | |
parent | 2fc4e793b12341df6264e22c0b8bd0f6dd2bd27d (diff) |
Manually destroy logger in popups
Diffstat (limited to 'editor')
-rwxr-xr-x | editor/ui.ml | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/editor/ui.ml b/editor/ui.ml index a4f5416..2cd8ff8 100755 --- a/editor/ui.ml +++ b/editor/ui.ml @@ -5,7 +5,14 @@ module Js = Js_of_ocaml.Js let popup : title:Jstr.t -> ?form:Forms.Events.t option -> 'a option Note.E.send -> El.t = fun ~title ?(form = None) send -> - let _ = send in + + (* Ensure we keep a track for the signal event. + + This looks a bit like the old memory magment in C, as it require to + destroy the logger each time the popup is removed. *) + let log_opt = Option.map + (fun (values, _) -> Note.S.log values (fun _ -> ())) + form in let close_btn = El.span @@ -15,7 +22,10 @@ let popup Evr.endless_listen (El.as_target close_btn) Ev.click - (fun _ -> send None); + (fun _ -> + Option.iter Note.Logr.destroy log_opt; + send None + ); let container = match form with | None -> El.div @@ -25,26 +35,24 @@ let popup | None -> El.div [] | Some (_, content) -> content - and footer = match form with | None -> El.txt Jstr.empty | Some (values, _) -> - - let log = Note.S.log values (fun _ -> ()) in - let btn = El.input () ~at:At.[type' (Jstr.v "submit")] in Evr.endless_listen (El.as_target btn) Ev.click - (fun _ -> Note.Logr.force log - ; send (Some (Note.S.value values))); + (fun _ -> + Option.iter Note.Logr.force log_opt; + let form_content = (Note.S.value values) in + Option.iter Note.Logr.destroy log_opt; + send (Some form_content)); - El.div ~at:At.[class' (Jstr.v "row")] - [ btn ] - in + El.div [ btn ] + ~at:At.[class' (Jstr.v "row")] in let el = El.div ~at:At.[class' (Jstr.v "modal")] |