Skip to content

Commit

Permalink
cleanup in modal
Browse files Browse the repository at this point in the history
  • Loading branch information
Grazfather committed Oct 10, 2021
1 parent f7354fb commit 7628b47
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions lib/modal.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -247,22 +247,22 @@ switching menus in one place which is then powered by config.fnl.
99999)))

(fn show-modal-menu
[context]
[state]
"
Main API to display a modal and run side-effects
- Display the modal alert
Takes current modal state from our modal statemachine
Returns the function to cleanup everything it sets up
"
(lifecycle.enter-menu context.menu)
(modal-alert context.menu)
(let [unbind-keys (bind-menu-keys context.menu.items)
stop-timeout context.stop-timeout]
(lifecycle.enter-menu state.context.menu)
(modal-alert state.context.menu)
(let [unbind-keys (bind-menu-keys state.context.menu.items)
stop-timeout state.context.stop-timeout]
(fn []
(hs.alert.closeAll 0)
(unbind-keys)
(call-when stop-timeout)
(lifecycle.exit-menu context.menu)
(lifecycle.exit-menu state.context.menu)
)))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Expand Down Expand Up @@ -455,14 +455,10 @@ switching menus in one place which is then powered by config.fnl.
(when state.context.history
(log.df (hs.inspect (map #(. $1 :title) state.context.history)))))))

; TODO: Bind show-modal-menu direct
; TODO: Do we only need one effect?
(local modal-effect
(statemachine.effect-handler
{:show-modal-menu (fn [state extra]
(show-modal-menu state.context))
:open-submenu (fn [state extra]
(show-modal-menu state.context))}))
{:show-modal-menu show-modal-menu
:open-submenu show-modal-menu}))

(fn proxy-app-action
[[action data]]
Expand Down

0 comments on commit 7628b47

Please sign in to comment.