mirror of
https://github.com/hzrd149/nostrudel.git
synced 2025-03-29 11:12:12 +01:00
fix error handling on launchpad
This commit is contained in:
parent
5f789d2c15
commit
a7a9f9d2c2
@ -2,12 +2,14 @@ import { useCallback } from "react";
|
||||
import { Button, Card, CardBody, CardHeader, CardProps, Heading, Link } from "@chakra-ui/react";
|
||||
import { Link as RouterLink, useNavigate } from "react-router-dom";
|
||||
import { NostrEvent } from "nostr-tools";
|
||||
import { getEventUID } from "nostr-idb";
|
||||
|
||||
import KeyboardShortcut from "../../../components/keyboard-shortcut";
|
||||
import { useNotifications } from "../../../providers/global/notifications-provider";
|
||||
import useSubject from "../../../hooks/use-subject";
|
||||
import { NotificationType, typeSymbol } from "../../../classes/notifications";
|
||||
import NotificationItem from "../../notifications/components/notification-item";
|
||||
import { ErrorBoundary } from "../../../components/error-boundary";
|
||||
|
||||
export default function NotificationsCard({ ...props }: Omit<CardProps, "children">) {
|
||||
const navigate = useNavigate();
|
||||
@ -42,7 +44,9 @@ export default function NotificationsCard({ ...props }: Omit<CardProps, "childre
|
||||
</CardHeader>
|
||||
<CardBody overflowX="hidden" overflowY="auto" pt="4" display="flex" flexDirection="column">
|
||||
{limit.map((event) => (
|
||||
<NotificationItem event={event} key={event.id} onClick={handleClick} visible />
|
||||
<ErrorBoundary key={getEventUID(event)}>
|
||||
<NotificationItem event={event} onClick={handleClick} visible />
|
||||
</ErrorBoundary>
|
||||
))}
|
||||
<Button as={RouterLink} to="/notifications" flexShrink={0} variant="link" size="lg" py="4">
|
||||
View More
|
||||
|
@ -15,6 +15,7 @@ import UserName from "../../../components/user/user-name";
|
||||
import HoverLinkOverlay from "../../../components/hover-link-overlay";
|
||||
import useShareableEventAddress from "../../../hooks/use-shareable-event-address";
|
||||
import KeyboardShortcut from "../../../components/keyboard-shortcut";
|
||||
import { ErrorBoundary } from "../../../components/error-boundary";
|
||||
|
||||
function LiveStream({ stream }: { stream: ParsedStream }) {
|
||||
const naddr = useShareableEventAddress(stream.event);
|
||||
@ -54,8 +55,13 @@ function StreamsCardContent({ ...props }: Omit<CardProps, "children">) {
|
||||
const timeline = useTimelineLoader(`${listId ?? "global"}-streams`, relays, query, { eventFilter });
|
||||
|
||||
const streams = useSubject(timeline.timeline)
|
||||
.map((event) => parseStreamEvent(event))
|
||||
.filter((stream) => !!stream.streaming)
|
||||
.map((event) => {
|
||||
try {
|
||||
return parseStreamEvent(event);
|
||||
} catch (e) {}
|
||||
})
|
||||
.filter((s) => !!s)
|
||||
.filter((stream) => stream.status !== "ended")
|
||||
.slice(0, 6);
|
||||
|
||||
return (
|
||||
@ -70,7 +76,9 @@ function StreamsCardContent({ ...props }: Omit<CardProps, "children">) {
|
||||
</CardHeader>
|
||||
<CardBody overflowX="hidden" overflowY="auto" pt="4" display="flex" gap="2" flexDirection="column" maxH="50vh">
|
||||
{streams.map((stream) => (
|
||||
<LiveStream key={getEventUID(stream.event)} stream={stream} />
|
||||
<ErrorBoundary key={getEventUID(stream.event)}>
|
||||
<LiveStream stream={stream} />
|
||||
</ErrorBoundary>
|
||||
))}
|
||||
<Button as={RouterLink} to="/streams" flexShrink={0} variant="link" size="lg" py="4">
|
||||
View More
|
||||
@ -82,8 +90,10 @@ function StreamsCardContent({ ...props }: Omit<CardProps, "children">) {
|
||||
|
||||
export default function StreamsCard({ ...props }: Omit<CardProps, "children">) {
|
||||
return (
|
||||
<PeopleListProvider initList="following">
|
||||
<StreamsCardContent {...props} />
|
||||
</PeopleListProvider>
|
||||
<ErrorBoundary>
|
||||
<PeopleListProvider initList="following">
|
||||
<StreamsCardContent {...props} />
|
||||
</PeopleListProvider>
|
||||
</ErrorBoundary>
|
||||
);
|
||||
}
|
||||
|
@ -40,11 +40,22 @@ function LaunchpadPage() {
|
||||
</Button>
|
||||
<SearchForm flex={1} />
|
||||
</Flex>
|
||||
<FeedsCard w="full" />
|
||||
<NotificationsCard w={{ base: "full", md: "calc(60% - 1rem)" }} maxH="40vh" />
|
||||
<DMsCard w={{ base: "full", md: "40%" }} />
|
||||
<StreamsCard w={{ base: "full", md: "40%" }} />
|
||||
<ToolsCard w={{ base: "full", md: "calc(60% - 1rem)" }} />
|
||||
|
||||
<ErrorBoundary>
|
||||
<FeedsCard w="full" />
|
||||
</ErrorBoundary>
|
||||
<ErrorBoundary>
|
||||
<NotificationsCard w={{ base: "full", md: "calc(60% - 1rem)" }} maxH="40vh" />
|
||||
</ErrorBoundary>
|
||||
<ErrorBoundary>
|
||||
<DMsCard w={{ base: "full", md: "40%" }} />
|
||||
</ErrorBoundary>
|
||||
<ErrorBoundary>
|
||||
<StreamsCard w={{ base: "full", md: "40%" }} />
|
||||
</ErrorBoundary>
|
||||
<ErrorBoundary>
|
||||
<ToolsCard w={{ base: "full", md: "calc(60% - 1rem)" }} />
|
||||
</ErrorBoundary>
|
||||
</VerticalPageLayout>
|
||||
);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user