diff options
author | Miguel Ángel Moreno <mail@migalmoreno.com> | 2024-01-22 01:10:40 +0100 |
---|---|---|
committer | Miguel Ángel Moreno <mail@migalmoreno.com> | 2024-01-22 01:10:40 +0100 |
commit | b9a2945b6bae73a34662cf17c66527b12e0ee402 (patch) | |
tree | dc0637bebd44c1ef21aa59a7ae5998303d7c81c4 /src/frontend | |
parent | 78d17927f0b36bf7e5e3f7e784049937063aec61 (diff) |
feat(frontend): refine existing events
Diffstat (limited to 'src/frontend')
-rw-r--r-- | src/frontend/tubo/events.cljs | 31 |
1 files 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 @@ -90,13 +94,6 @@ ::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)] (fn [{:keys [db store]} [_ value player]] @@ -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)})) |