From d7da6114e55896de7e8b75fc595bb7869b858bc6 Mon Sep 17 00:00:00 2001 From: Miguel Ángel Moreno Date: Tue, 3 Dec 2024 23:04:03 +0100 Subject: feat: reset channel state on leaving channel route --- src/frontend/tubo/channel/events.cljs | 5 +++++ src/frontend/tubo/routes.cljs | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'src') 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 -- cgit v1.2.3