diff options
Diffstat (limited to 'editor/actions')
-rwxr-xr-x | editor/actions/import.ml | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/editor/actions/import.ml b/editor/actions/import.ml index cb0c16d..4cac76c 100755 --- a/editor/actions/import.ml +++ b/editor/actions/import.ml @@ -1,5 +1,21 @@ module Js = Js_of_ocaml.Js +let uncheck_import = + fun ~previous ~update -> + let _ = previous + and _ = update in + true + +let check_import = + fun ~previous ~update -> + Js.Opt.case previous##.date + (fun () -> true) + (fun previous_date -> + Js.Opt.case update##.date + (fun () -> true) + (fun update_date -> + update_date >= previous_date )) + module M = struct type t = Forms.Selector.t @@ -7,13 +23,20 @@ module M = struct let update : t -> State.t -> State.t = fun t state -> - match t with + match t.Forms.Selector.file with | None -> state | Some file -> - (* Back to UTF-16 *) let content = file.Elements.Input.content in - Brr.Console.(log [content] ); - match State.Storage.of_json content with + let check = + if t.Forms.Selector.preserve_newest then + check_import + else + uncheck_import + in + match + State.Storage.of_json + ~check + content with | Error _ -> state | Ok _obj -> State.load_page state.State.page_id state |