Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 49 additions & 32 deletions app/application.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1643,8 +1643,7 @@ type command =
| Capture_asset of Journal_asset_import.event
| Timeline_retry of string
| Detail_open of string
| Detail_expand of string
| Detail_collapse of string
| Detail_visible_range of int64 * int64
| Detail_more of string
| Detail_task_intent of string
| Detail_submit of string
Expand Down Expand Up @@ -2827,7 +2826,7 @@ module Detail_list = struct
match row with
| Journal_detail.More _ ->
V.Native_list.row ~key:row_key ~separator:Hidden label
| Block { block; expanded; leaf; _ } ->
| Block { block; _ } ->
let id = Journal_model.id block in
let delete = bind_action on_action (Detail_delete id) in
let open_block = bind_action on_action (Detail_open id) in
Expand Down Expand Up @@ -2855,15 +2854,7 @@ module Detail_list = struct
~symbol:"doc.on.doc"
~on_press:(bind_action on_action (Copy_block id))
()
]
|> fun actions ->
if leaf then actions else
V.Context_menu.action
~key:(Ui.Key.string (if expanded then "collapse" else "expand"))
~title:(if expanded then "Hide children" else "Show children")
~on_press:(bind_action on_action
(if expanded then Detail_collapse id else Detail_expand id))
() :: actions)
])
()
in
V.Native_list.row ~key:row_key ~separator:Hidden ~context_menu label
Expand Down Expand Up @@ -2921,37 +2912,36 @@ let detail_page
{ dispatch with send = (fun action -> dispatch.send (Detail_action (scope, action))) }
in
let on_action action = bind_action local action in
let button ~id ~command ~symbol title =
V.buttons
~actions:
[ V.buttons_action
~label:title
~icon:symbol
~text:title
~on_press:(on_action command)
()
]
let button ?(enabled = true) ~id ~command ~symbol title =
V.button
~enabled
~on_press:(on_action command)
~child:(V.label ~title:(V.text title) ~icon:(V.symbol ~name:symbol ()) ())
()
|> V.with_test_id (Ui.Test_id.string id)
in
let rows detail =
List.map
(function
| Journal_detail.More { parent_id; loading; error; _ } ->
| Journal_detail.More { parent_id; loading; enabled; error; _ } ->
if loading
then V.loading ~message:"Loading children" ()
else
V.column
(Option.to_list (Option.map live_region_text error)
@ [ button
~enabled
~id:("detail-more:" ^ parent_id)
~command:(Detail_more parent_id)
~symbol:
(if Option.is_some error then "arrow.clockwise" else "ellipsis")
(if Option.is_some error
then "Retry loading children"
else "Load more")
])
]
@ if enabled
then []
else [ V.text "Waiting for another branch to finish" ])
| Block { block; depth; _ } ->
let source =
if Journal_model.task_state block = No_status
Expand Down Expand Up @@ -2994,6 +2984,7 @@ let detail_page
~on_visible_range:
(Ui.Event.Handler.create (function
| Ui.Event.Payload.Visible_range range ->
local.send (Detail_visible_range (range.first_index, range.last_exclusive));
dispatch.send
(Media_range
( media_presentation_scope state ~detail:true
Expand Down Expand Up @@ -4932,6 +4923,28 @@ let start
}
| _ -> state)))
in
let detail_drain_key state =
if not state.graph_ready
then None
else
Option.bind (Journal_routes.detail state.routes) (fun detail ->
Option.map
(fun block_id -> Journal_detail.session_id detail, block_id)
(Journal_detail.next_automatic_load detail))
in
let prev_detail_drain_key = ref (detail_drain_key initial_state) in
let detail_drain_callback = function
| None -> Effect.ignore
| Some (session, block_id) ->
set_state_and_effect (fun state ->
match Journal_routes.detail state.routes with
| Some detail when state.graph_ready && Journal_detail.session_id detail = session
&& Journal_detail.next_automatic_load detail = Some block_id ->
let detail, requests = Journal_detail.step detail Load_next in
{ state with routes = Journal_routes.update_detail state.routes detail },
Effect.many (List.map send requests)
| _ -> state, Effect.ignore)
in
let prev_capture_imports_key = ref initial_state.capture_imports in
let rec drain_imports () =
if Hashtbl.length capture_staged_items > 0 || Queue.is_empty capture_import_queue
Expand Down Expand Up @@ -5138,9 +5151,11 @@ let start
let detail_event event =
match Journal_routes.detail snapshot.routes with
| None -> Effect.ignore
| Some detail ->
let detail, requests = Journal_detail.step detail event in
Effect.bind
| Some previous ->
let detail, requests = Journal_detail.step previous event in
if detail == previous && requests = []
then Effect.ignore
else Effect.bind
(update (fun state ->
{ state with routes = Journal_routes.update_detail state.routes detail }))
~f:(fun () -> Effect.many (List.map send requests))
Expand Down Expand Up @@ -5755,8 +5770,8 @@ let start
update (fun state ->
{ state with timeline = Journal_timeline_state.retry_day state.timeline ~day }))
| Detail_open value -> open_block value
| Detail_expand value -> detail_event (Set_branch_expanded (value, true))
| Detail_collapse value -> detail_event (Set_branch_expanded (value, false))
| Detail_visible_range (first, last) ->
detail_event (Observe_visible_range (first, last))
| Detail_more value -> detail_event (Load_more value)
| Detail_task_intent value -> update_draft ~toggle:true value
| Detail_retry ->
Expand Down Expand Up @@ -6060,6 +6075,11 @@ let start
then (
prev_timeline_drain_key := key;
Effect.run (timeline_drain_callback key)));
(let key = detail_drain_key model in
if not (!prev_detail_drain_key = key)
then (
prev_detail_drain_key := key;
Effect.run (detail_drain_callback key)));
(let key = upload_context model in
if not (!prev_upload_key = key)
then (
Expand Down Expand Up @@ -7060,7 +7080,6 @@ module For_testing = struct
| Attach_file
| Open_block of string
| Delete_block of string
| Set_expanded of string * bool
| Load_more of string
| Retry
| Submit of string
Expand Down Expand Up @@ -7090,8 +7109,6 @@ module For_testing = struct
| Detail_action (_, Open_append) -> on_action Append
| Detail_action (_, Detail_open id) -> on_action (Open_block id)
| Detail_action (_, Detail_delete id) -> on_action (Delete_block id)
| Detail_action (_, Detail_expand id) -> on_action (Set_expanded (id, true))
| Detail_action (_, Detail_collapse id) -> on_action (Set_expanded (id, false))
| Detail_action (_, Detail_more id) -> on_action (Load_more id)
| Detail_action (_, Detail_retry) -> on_action Retry
| Detail_action (_, Detail_submit source) -> on_action (Submit source)
Expand Down
1 change: 0 additions & 1 deletion app/application.mli
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ module For_testing : sig
| Attach_file
| Open_block of string
| Delete_block of string
| Set_expanded of string * bool
| Load_more of string
| Retry
| Submit of string
Expand Down
Loading
Loading