Skip to content

Commit 1c068dd

Browse files
committed
fix(web-app): Disable the Sync button at load time
This fixes "bug 0" of issue ocaml-sf#505.
1 parent 9bc28a6 commit 1c068dd

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/app/learnocaml_common.ml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(* This file is part of Learn-OCaml.
22
*
3-
* Copyright (C) 2019-2020 OCaml Software Foundation.
3+
* Copyright (C) 2019-2022 OCaml Software Foundation.
44
* Copyright (C) 2016-2018 OCamlPro.
55
*
66
* Learn-OCaml is distributed under the terms of the MIT license. See the
@@ -976,7 +976,10 @@ module Editor_button (E : Editor_info) = struct
976976
sync_exercise token id ~editor:(Ace.get_contents E.ace) on_sync
977977
>|= fun _save -> ());
978978
Ace.register_sync_observer E.ace (fun sync ->
979-
if sync then disable_button state else enable_button state)
979+
(* this is run twice when clicking on Reset, because of Ace's implem *)
980+
if sync then disable_button state else enable_button state);
981+
(* Disable the Sync button at loading time: *)
982+
Ace.set_synchronized E.ace
980983
981984
end
982985
@@ -989,6 +992,7 @@ let setup_editor id solution =
989992
in
990993
let ace = Ocaml_mode.get_editor editor in
991994
Ace.set_contents ace ~reset_undo:true solution;
995+
(* "Ace.set_synchronized ace" done after "Ace.register_sync_observer" above *)
992996
Ace.set_font_size ace 18;
993997
editor, ace
994998

0 commit comments

Comments
 (0)