From a4fbb1b4c5339fefba5c64bd09882981dec3a2e8 Mon Sep 17 00:00:00 2001 From: Philipp Heckel Date: Sun, 6 Mar 2022 16:35:31 -0500 Subject: [PATCH] Home button --- web/src/components/ActionBar.js | 2 ++ web/src/components/App.js | 20 +++++++++++++++++++- web/src/components/Navigation.js | 5 +++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/web/src/components/ActionBar.js b/web/src/components/ActionBar.js index 994cd4e8..88e36dcd 100644 --- a/web/src/components/ActionBar.js +++ b/web/src/components/ActionBar.js @@ -89,6 +89,8 @@ const SettingsIcon = (props) => { const newSelected = await subscriptionManager.first(); // May be undefined if (newSelected) { navigate(subscriptionRoute(newSelected)); + } else { + navigate("/"); } }; diff --git a/web/src/components/App.js b/web/src/components/App.js index 61fbf18d..fa09c826 100644 --- a/web/src/components/App.js +++ b/web/src/components/App.js @@ -23,7 +23,6 @@ import {subscriptionRoute} from "../app/utils"; // TODO support unsubscribed routes // TODO add "home" route that is selected when nothing else fits // TODO new notification indicator -// TODO sound autoplay error warning // TODO "copy url" toast // TODO "copy link url" button // TODO races when two tabs are open @@ -49,6 +48,7 @@ const Root = () => { const subscriptions = useLiveQuery(() => subscriptionManager.all()); const selectedSubscription = findSelected(location, subscriptions); + console.log(window.location); const handleSubscribeSubmit = async (subscription) => { console.log(`[App] New subscription: ${subscription.id}`, subscription); navigate(subscriptionRoute(subscription)); @@ -148,6 +148,24 @@ const findSelected = (location, subscriptions) => { } const [subscription] = subscriptions.filter(s => location.pathname === subscriptionRoute(s)); return subscription; + + /* + if (location.pathname === "/" || location.pathname === "/settings") { + return null; + } + if (!subscription) { + const [, topic] = location.pathname.split("/"); + const subscription = { + id: topicUrl(window.location.origin, topic), + baseUrl: window.location.origin, + topic: topic, + last: "" + } + subscriptionManager.save(subscription); + return subscription; + } + + */ }; export default App; diff --git a/web/src/components/Navigation.js b/web/src/components/Navigation.js index c8f9fd5c..ee251a9b 100644 --- a/web/src/components/Navigation.js +++ b/web/src/components/Navigation.js @@ -9,6 +9,7 @@ import Toolbar from "@mui/material/Toolbar"; import Divider from "@mui/material/Divider"; import List from "@mui/material/List"; import SettingsIcon from "@mui/icons-material/Settings"; +import HomeIcon from '@mui/icons-material/Home'; import AddIcon from "@mui/icons-material/Add"; import SubscribeDialog from "./SubscribeDialog"; import {Alert, AlertTitle, CircularProgress, ListSubheader} from "@mui/material"; @@ -86,6 +87,10 @@ const NavList = (props) => { /> } + navigate("/")} selected={location.pathname === "/"}> + + + navigate("/settings")} selected={location.pathname === "/settings"}>