aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMiguel Ángel Moreno <mail@migalmoreno.com>2024-12-03 23:04:03 +0100
committerMiguel Ángel Moreno <mail@migalmoreno.com>2024-12-03 23:04:03 +0100
commitd7da6114e55896de7e8b75fc595bb7869b858bc6 (patch)
treed679a385f7cd55aed5b3b76ff061c02101553c6d /src
parent1bcebadef3b0ac836b3f0b8ee5df30f7c493cf38 (diff)
feat: reset channel state on leaving channel route
Diffstat (limited to 'src')
-rw-r--r--src/frontend/tubo/channel/events.cljs5
-rw-r--r--src/frontend/tubo/routes.cljs3
2 files changed, 7 insertions, 1 deletions
diff --git a/src/frontend/tubo/channel/events.cljs b/src/frontend/tubo/channel/events.cljs
index 3e529df..49ed26a 100644
--- a/src/frontend/tubo/channel/events.cljs
+++ b/src/frontend/tubo/channel/events.cljs
@@ -90,3 +90,8 @@
{:nextPage (js/encodeURIComponent next-page-url)})
:db
(assoc db :show-pagination-loading true)))))
+
+(rf/reg-event-db
+ :channel/reset
+ (fn [db _]
+ (assoc db :channel nil)))
diff --git a/src/frontend/tubo/routes.cljs b/src/frontend/tubo/routes.cljs
index 2086a27..8e72d09 100644
--- a/src/frontend/tubo/routes.cljs
+++ b/src/frontend/tubo/routes.cljs
@@ -36,7 +36,8 @@
:name :channel-page
:controllers [{:parameters {:query [:url]}
:start (fn [{{:keys [url]} :query}]
- (rf/dispatch [:channel/fetch-page url]))}]}]
+ (rf/dispatch [:channel/fetch-page url]))
+ :stop #(rf/dispatch [:channel/reset])}]}]
["/playlist"
{:view playlist/playlist
:name :playlist-page