mirror of
https://github.com/hzrd149/nostrudel.git
synced 2025-03-17 21:31:43 +01:00
make home tabs controlled
This commit is contained in:
parent
1d34ec31eb
commit
ca8df3fff5
19
src/app.tsx
19
src/app.tsx
@ -21,6 +21,14 @@ const RequireSetup = ({ children }: { children: JSX.Element }) => {
|
||||
return children;
|
||||
};
|
||||
|
||||
const HomePage = () => (
|
||||
<RequireSetup>
|
||||
<Page>
|
||||
<HomeView />
|
||||
</Page>
|
||||
</RequireSetup>
|
||||
);
|
||||
|
||||
export const App = () => {
|
||||
return (
|
||||
<ErrorBoundary>
|
||||
@ -72,16 +80,7 @@ export const App = () => {
|
||||
</RequireSetup>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path="/"
|
||||
element={
|
||||
<RequireSetup>
|
||||
<Page>
|
||||
<HomeView />
|
||||
</Page>
|
||||
</RequireSetup>
|
||||
}
|
||||
/>
|
||||
<Route path="/*" element={<HomePage />} />
|
||||
</Routes>
|
||||
</ErrorBoundary>
|
||||
);
|
||||
|
@ -40,6 +40,13 @@ export const PostMenu = ({ event }: { event: NostrEvent }) => {
|
||||
>
|
||||
Open in BRB
|
||||
</MenuItem>
|
||||
<MenuItem
|
||||
as="a"
|
||||
href={`https://snort.social/e/${event.id}`}
|
||||
target="_blank"
|
||||
>
|
||||
Open in snort.social
|
||||
</MenuItem>
|
||||
<MenuItem onClick={() => copyToClipboard(event.id)}>
|
||||
Copy {truncatedId(event.id)}
|
||||
</MenuItem>
|
||||
|
@ -1,8 +1,15 @@
|
||||
import { Tab, TabList, TabPanel, TabPanels, Tabs } from "@chakra-ui/react";
|
||||
import { useMatch, useNavigate } from "react-router-dom";
|
||||
import { DiscoverTab } from "./discover-tab";
|
||||
import { FollowingTab } from "./following-tab";
|
||||
|
||||
export const HomeView = () => {
|
||||
const navigate = useNavigate();
|
||||
const followingMatch = useMatch("/following");
|
||||
const discoverMatch = useMatch("/discover");
|
||||
|
||||
const tabs = ["/following", "/discover"];
|
||||
|
||||
return (
|
||||
<Tabs
|
||||
display="flex"
|
||||
@ -10,6 +17,8 @@ export const HomeView = () => {
|
||||
flexGrow="1"
|
||||
overflow="hidden"
|
||||
isLazy
|
||||
index={discoverMatch ? 1 : 0}
|
||||
onChange={(v) => navigate(tabs[v])}
|
||||
>
|
||||
<TabList>
|
||||
<Tab>Following</Tab>
|
||||
|
Loading…
x
Reference in New Issue
Block a user