diff options
author | Miguel Ángel Moreno <mail@migalmoreno.com> | 2024-01-28 02:51:27 +0100 |
---|---|---|
committer | Miguel Ángel Moreno <mail@migalmoreno.com> | 2024-01-28 03:00:13 +0100 |
commit | 6d6b8e8799a264ae419fb5de1bdeeae41a3ea010 (patch) | |
tree | 8b8141fd38b1ef8f560b7fe42e5a945f3b92aef2 /src | |
parent | 999b9a6d6c4c4bf15c08f8a06c09f08876a90b7d (diff) |
feat(frontend): add document title effect
Diffstat (limited to 'src')
-rw-r--r-- | src/frontend/tubo/events.cljs | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/frontend/tubo/events.cljs b/src/frontend/tubo/events.cljs index 889719d..98953b3 100644 --- a/src/frontend/tubo/events.cljs +++ b/src/frontend/tubo/events.cljs @@ -55,6 +55,11 @@ (set! (.. js/document.body -style -overflow) (if active "hidden" "auto")))) (rf/reg-fx + ::document-title! + (fn [title] + (set! (.-title js/document) (str title " - Tubo")))) + +(rf/reg-fx ::player-volume (fn [{:keys [player volume]}] (when (and @player (> (.-readyState @player) 0)) @@ -485,7 +490,8 @@ (let [kiosk-res (js->clj res :keywordize-keys true)] {:db (assoc db :kiosk kiosk-res :show-page-loading false) - :fx [[:dispatch [::set-service-styles kiosk-res]]]}))) + :fx [[:dispatch [::set-service-styles kiosk-res]] + [::document-title! (:id kiosk-res)]]}))) (rf/reg-event-fx ::get-default-kiosk-page @@ -562,10 +568,10 @@ (let [stream-res (js->clj res :keywordize-keys true)] {:db (assoc db :stream stream-res :show-page-loading false) - :fx [[:dispatch [::change-stream-format nil]] - (when (and (-> db :settings :show-comments)) + :fx [(when (and (-> db :settings :show-comments)) [:dispatch [::get-comments (:url stream-res)]]) - [:dispatch [::set-service-styles stream-res]]]}))) + [:dispatch [::set-service-styles stream-res]] + [::document-title! (:name stream-res)]]}))) (rf/reg-event-fx ::fetch-stream-page @@ -605,7 +611,8 @@ (let [channel-res (js->clj res :keywordize-keys true)] {:db (assoc db :channel channel-res :show-page-loading false) - :fx [[:dispatch [::set-service-styles channel-res]]]}))) + :fx [[:dispatch [::set-service-styles channel-res]] + [::document-title! (:name channel-res)]]}))) (rf/reg-event-fx ::get-channel-page @@ -622,7 +629,8 @@ (let [playlist-res (js->clj res :keywordize-keys true)] {:db (assoc db :playlist playlist-res :show-page-loading false) - :fx [[:dispatch [::set-service-styles playlist-res]]]}))) + :fx [[:dispatch [::set-service-styles playlist-res]] + [::document-title! (:name playlist-res)]]}))) (rf/reg-event-fx ::get-playlist-page @@ -648,7 +656,8 @@ [::load-search-results] [::bad-response] {:q query}) :db (assoc db :show-page-loading true - :show-search-form true)))) + :show-search-form true) + :fx [[::document-title! (str "Search for \"" query "\"")]]))) (rf/reg-event-fx ::change-setting |