From b9a2945b6bae73a34662cf17c66527b12e0ee402 Mon Sep 17 00:00:00 2001 From: Miguel Ángel Moreno Date: Mon, 22 Jan 2024 01:10:40 +0100 Subject: feat(frontend): refine existing events --- src/frontend/tubo/events.cljs | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/src/frontend/tubo/events.cljs b/src/frontend/tubo/events.cljs index 7b2690a..c4086ab 100644 --- a/src/frontend/tubo/events.cljs +++ b/src/frontend/tubo/events.cljs @@ -43,20 +43,15 @@ (.scrollTo js/window #js {"top" 0 "behavior" "smooth"}))) (rf/reg-fx - ::history-back! - (fn [_] - (.back js/window.history))) + ::history-go! + (fn [idx] + (.go js/window.history idx))) (rf/reg-fx ::body-overflow! (fn [active] (set! (.. js/document.body -style -overflow) (if active "hidden" "auto")))) -(rf/reg-event-fx - ::history-back - (fn [_ _] - {::history-back! nil})) - (rf/reg-fx ::player-volume (fn [{:keys [player volume]}] @@ -76,6 +71,15 @@ (if paused? (.play player) (.pause player))))) +(rf/reg-event-fx + ::history-go + (fn [_ [_ idx]] + {::history-go! idx})) + +(rf/reg-event-db + ::toggle-search-form + (fn [db _] + (assoc db :show-search-form (not (:show-search-form db))))) (rf/reg-event-fx ::toggle-mobile-nav @@ -89,13 +93,6 @@ {:db (assoc db :show-media-queue (not (:show-media-queue db))) ::body-overflow! (not (:show-media-queue db))})) -(rf/reg-event-fx - ::toggle-loop-file - [(rf/inject-cofx :store)] - (fn [{:keys [db store]} _] - {:db (assoc db :loop-file (not (:loop-file db))) - :store (assoc store :loop-file (not (:loop-file store)))})) - (rf/reg-event-fx ::change-volume-level [(rf/inject-cofx :store)] @@ -558,8 +555,8 @@ :db (assoc db :show-page-loading true)))) (rf/reg-event-fx - ::change-setting + ::change-setting [(rf/inject-cofx :store)] (fn [{:keys [db store]} [_ key val]] - {:db (assoc-in db [:settings key] val) + {:db (assoc-in db [:settings key] val) :store (assoc store key val)})) -- cgit v1.2.3