aboutsummaryrefslogtreecommitdiff
path: root/src/frontend
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontend')
-rw-r--r--src/frontend/tubo/events.cljs68
-rw-r--r--src/frontend/tubo/kiosks/events.cljs39
-rw-r--r--src/frontend/tubo/settings/views.cljs73
3 files changed, 112 insertions, 68 deletions
diff --git a/src/frontend/tubo/events.cljs b/src/frontend/tubo/events.cljs
index 6365a9b..874af84 100644
--- a/src/frontend/tubo/events.cljs
+++ b/src/frontend/tubo/events.cljs
@@ -32,32 +32,48 @@
(fn [{:keys [store]} _]
(let [if-nil #(if (nil? %1) %2 %1)]
{:db
- {:player/paused true
- :player/muted (:player/muted store)
- :queue (if-nil (:queue store) [])
- :service-id (if-nil (:service-id store) 0)
- :player/loop (if-nil (:player/loop store) :playlist)
- :queue/position (if-nil (:queue/position store) 0)
- :player/volume (if-nil (:player/volume store) 100)
- :bg-player/show (:bg-player/show store)
- :bookmarks (if-nil (:bookmarks store)
- [{:id (nano-id) :name "Liked Streams"}])
- :settings {:theme (if-nil (:theme store) "auto")
- :show-comments (if-nil (:show-comments store)
- true)
- :show-related (if-nil (:show-related store)
- true)
- :show-description (if-nil (:show-description
- store)
- true)
- :items-layout "list"
- :default-service (if-nil
- (:default-service store)
- {:service-id 0
- :id "YouTube"
- :default-kiosk "Trending"
- :available-kiosks
- ["Trending"]})}}})))
+ {:player/paused true
+ :player/muted (:player/muted store)
+ :player/shuffled (:player/shuffled store)
+ :player/loop (if-nil (:player/loop store) :playlist)
+ :player/volume (if-nil (:player/volume store) 100)
+ :bg-player/show (:bg-player/show store)
+ :queue (if-nil (:queue store) [])
+ :queue/position (if-nil (:queue/position store) 0)
+ :queue/unshuffled (:queue/unshuffled store)
+ :service-id (if-nil (:service-id store) 0)
+ :bookmarks (if-nil (:bookmarks store)
+ [{:id (nano-id) :name "Liked Streams"}])
+ :settings {:theme (if-nil (-> store
+ :settings
+ :theme)
+ "auto")
+ :show-comments (if-nil (-> store
+ :settings
+ :show-comments)
+ true)
+ :show-related (if-nil (-> store
+ :settings
+ :show-related)
+ true)
+ :show-description (if-nil (-> store
+ :settings
+ :show-description)
+ true)
+ :items-layout "list"
+ :default-country (if-nil (-> store
+ :settings
+ :default-country)
+ {0 {:name "United States"
+ :code "US"}})
+ :default-service (if-nil (-> store
+ :settings
+ :default-service)
+ {:service-id 0
+ :id "YouTube"
+ :default-kiosk "Trending"
+ :available-kiosks
+ ["Trending"]})}}})))
(rf/reg-fx
:scroll-to-top
diff --git a/src/frontend/tubo/kiosks/events.cljs b/src/frontend/tubo/kiosks/events.cljs
index 75fc9a2..3197daf 100644
--- a/src/frontend/tubo/kiosks/events.cljs
+++ b/src/frontend/tubo/kiosks/events.cljs
@@ -21,10 +21,11 @@
(rf/reg-event-fx
:kiosks/fetch-default
- (fn [_ [_ service-id on-success on-error]]
+ (fn [_ [_ service-id on-success on-error params]]
(api/get-request (str "/services/" service-id "/default-kiosk")
on-success
- on-error)))
+ on-error
+ params)))
(rf/reg-event-fx
:kiosks/fetch-all
@@ -58,15 +59,21 @@
(rf/reg-event-fx
:kiosks/fetch-page
(fn [{:keys [db]} [_ service-id kiosk-id]]
- {:db (assoc db
- :show-page-loading true
- :kiosk nil)
- :fx [[:dispatch
- (if kiosk-id
- [:kiosks/fetch service-id kiosk-id
- [:kiosks/load-page]
- [:kiosks/bad-page-response service-id kiosk-id]]
- [:kiosks/fetch-default-page service-id])]]}))
+ (let [default-country (-> db
+ :settings
+ :default-country
+ (get (js/parseInt service-id))
+ :code)]
+ {:db (assoc db
+ :show-page-loading true
+ :kiosk nil)
+ :fx [[:dispatch
+ (if kiosk-id
+ [:kiosks/fetch service-id kiosk-id
+ [:kiosks/load-page]
+ [:kiosks/bad-page-response service-id kiosk-id]
+ (when default-country {:region default-country})]
+ [:kiosks/fetch-default-page service-id])]]})))
(rf/reg-event-fx
:kiosks/fetch-default-page
@@ -80,13 +87,19 @@
(-> db
:settings
:default-service
- :default-kiosk))]
+ :default-kiosk))
+ default-country (-> db
+ :settings
+ :default-country
+ (get (js/parseInt service-id))
+ :code)]
{:fx [[:dispatch
(if default-kiosk-id
[:kiosks/fetch-page service-id default-kiosk-id]
[:kiosks/fetch-default service-id
[:kiosks/load-page]
- [:kiosks/bad-page-response service-id nil]])]]})))
+ [:kiosks/bad-page-response service-id nil]
+ (when default-country {:region default-country})])]]})))
(rf/reg-event-fx
:kiosks/change-page
diff --git a/src/frontend/tubo/settings/views.cljs b/src/frontend/tubo/settings/views.cljs
index 3afed5e..536d91c 100644
--- a/src/frontend/tubo/settings/views.cljs
+++ b/src/frontend/tubo/settings/views.cljs
@@ -15,45 +15,60 @@
(or on-change
#(rf/dispatch [:settings/change keys (.. % -target -value)]))])
-(defn general-settings
- [{:keys [theme default-service items-layout]}]
- (let [services @(rf/subscribe [:services])]
+(defn appearance-settings
+ [{:keys [theme items-layout]}]
+ [:<>
+ [select-input "Theme" [:theme] theme #{:auto :light :dark}]
+ [select-input "List view mode" [:items-layout] items-layout #{:grid :list}]])
+
+(defn content-settings
+ [{:keys [default-service default-country show-description show-comments
+ show-related]}]
+ (let [services @(rf/subscribe [:services])
+ service-id @(rf/subscribe [:service-id])
+ countries (->> services
+ (filter #(= (:id %) service-id))
+ first
+ :supported-countries)]
[:<>
- [select-input "Theme" :theme theme #{:auto :light :dark}]
- [select-input "Default service" :default-service (:id default-service)
+ [select-input "Default content country" nil
+ (:name (get default-country service-id)) (map :name countries)
+ (fn [e]
+ (rf/dispatch [:settings/change [:default-country service-id]
+ (first (filter #(= (.. e -target -value) (:name %))
+ countries))]))]
+ [select-input "Default service" [:default-service] (:id default-service)
(map #(-> %
:info
:name)
services)
#(rf/dispatch [:settings/change-service (.. % -target -value)])]
- [select-input "Default kiosk" :default-service
- (:default-kiosk default-service) (:available-kiosks default-service)
- #(rf/dispatch [:settings/change-kiosk (.. % -target -value)])]
- [select-input "Items Layout" :items-layout items-layout #{:grid :list}]]))
-
-(defn stream-settings
- [{:keys [show-description show-comments show-related]}]
- [:<>
- [boolean-input "Show description" :show-description show-description]
- [boolean-input "Show comments" :show-comments show-comments]
- [boolean-input "Show related videos" :show-related show-related]])
+ [select-input "Default kiosk" [:default-service :default-kiosk]
+ (:default-kiosk default-service) (:available-kiosks default-service)]
+ [boolean-input "Show comments" [:show-comments] show-comments]
+ [boolean-input "Show description" [:show-description] show-description]
+ [boolean-input "Show 'Next' and 'Similar' videos" [:show-related]
+ show-related]]))
(defn settings
[]
- (let [!active-tab (r/atom :general)]
+ (let [!active-tab (r/atom :content)]
(fn []
(let [settings @(rf/subscribe [:settings])]
[layout/content-container
[layout/content-header "Settings"]
- [layout/tabs
- [{:id :general
- :label "General"}
- {:id :stream
- :label "Stream"}]
- :selected-id @!active-tab
- :on-change #(reset! !active-tab %)]
- [:form.flex.flex-wrap.py-4
- (case @!active-tab
- :general [general-settings settings]
- :stream [stream-settings settings]
- [general-settings settings])]]))))
+ [:div.mt-4
+ [layout/tabs
+ [{:id :appearance
+ :label "Appearance"
+ :left-icon [:i.fa-solid.fa-palette]}
+ {:id :content
+ :label "Content"
+ :left-icon [:i.fa-solid.fa-globe]}]
+ :selected-id @!active-tab
+ :on-change #(reset! !active-tab %)]
+ [:form.flex.flex-wrap.py-4.gap-y-4
+ (case @!active-tab
+ :appearance [appearance-settings settings]
+ :content [content-settings settings]
+ [appearance-settings settings])]]]))))