mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-07 22:28:48 +00:00
place error boundaries closer to the source
This commit is contained in:
parent
88c774339d
commit
ea96999377
6 changed files with 31 additions and 21 deletions
|
@ -8,7 +8,6 @@ import { useEffect, useContext, useState } from "react";
|
|||
import { BiError } from "react-icons/bi";
|
||||
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
|
||||
|
||||
import ErrorBoundary from "components/errorboundry";
|
||||
import ServicesGroup from "components/services/group";
|
||||
import BookmarksGroup from "components/bookmarks/group";
|
||||
import Widget from "components/widgets/widget";
|
||||
|
@ -20,6 +19,7 @@ import { ColorContext } from "utils/contexts/color";
|
|||
import { ThemeContext } from "utils/contexts/theme";
|
||||
import { SettingsContext } from "utils/contexts/settings";
|
||||
import { bookmarksResponse, servicesResponse, widgetsResponse } from "utils/config/api-response";
|
||||
import ErrorBoundary from "components/errorboundry";
|
||||
|
||||
const ThemeToggle = dynamic(() => import("components/toggles/theme"), {
|
||||
ssr: false,
|
||||
|
@ -145,7 +145,9 @@ function Index({ initialSettings, fallback }) {
|
|||
|
||||
return (
|
||||
<SWRConfig value={{ fallback, fetcher: (resource, init) => fetch(resource, init).then((res) => res.json()) }}>
|
||||
<Home initialSettings={initialSettings} />
|
||||
<ErrorBoundary>
|
||||
<Home initialSettings={initialSettings} />
|
||||
</ErrorBoundary>
|
||||
</SWRConfig>
|
||||
);
|
||||
}
|
||||
|
@ -192,14 +194,14 @@ function Home({ initialSettings }) {
|
|||
{widgets
|
||||
.filter((widget) => !rightAlignedWidgets.includes(widget.type))
|
||||
.map((widget, i) => (
|
||||
<ErrorBoundary key={i}><Widget key={i} widget={widget} /></ErrorBoundary>
|
||||
<Widget key={i} widget={widget} />
|
||||
))}
|
||||
|
||||
<div className="ml-4 flex flex-wrap basis-full grow sm:basis-auto justify-between md:justify-end mt-2 md:mt-0">
|
||||
{widgets
|
||||
.filter((widget) => rightAlignedWidgets.includes(widget.type))
|
||||
.map((widget, i) => (
|
||||
<ErrorBoundary key={i}><Widget key={i} widget={widget} /></ErrorBoundary>
|
||||
<Widget key={i} widget={widget} />
|
||||
))}
|
||||
</div>
|
||||
</>
|
||||
|
@ -209,7 +211,7 @@ function Home({ initialSettings }) {
|
|||
{services && (
|
||||
<div className="flex flex-wrap p-8 items-start">
|
||||
{services.map((group) => (
|
||||
<ErrorBoundary key={group.name}><ServicesGroup key={group.name} services={group} layout={initialSettings.layout?.[group.name]} /></ErrorBoundary>
|
||||
<ServicesGroup key={group.name} services={group} layout={initialSettings.layout?.[group.name]} />
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
@ -217,7 +219,7 @@ function Home({ initialSettings }) {
|
|||
{bookmarks && (
|
||||
<div className="grow flex flex-wrap pt-0 p-8">
|
||||
{bookmarks.map((group) => (
|
||||
<ErrorBoundary key={group.name}><BookmarksGroup key={group.name} group={group} /></ErrorBoundary>
|
||||
<BookmarksGroup key={group.name} group={group} />
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue