feat: prevent getting null site
This commit is contained in:
parent
2ed3d9b366
commit
20d0c3c1bb
|
|
@ -8,7 +8,7 @@ import { toIPFS, toGateway } from "~/lib/ipfs-parser"
|
|||
import { IPFS_SW_GATEWAY_PREFIX } from "~/lib/ipfs-gateway"
|
||||
|
||||
export const BlockchainInfo: React.FC<{
|
||||
site?: Profile
|
||||
site?: Profile | null
|
||||
page?: Note | null
|
||||
}> = ({ site, page }) => {
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import Script from "next/script"
|
|||
import Image from "next/image"
|
||||
|
||||
export const SiteFooter: React.FC<{
|
||||
site?: Profile
|
||||
site?: Profile | null
|
||||
page?: Note | null
|
||||
}> = ({ site, page }) => {
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ const HeaderLink: React.FC<{ link: HeaderLinkType }> = ({ link }) => {
|
|||
}
|
||||
|
||||
export const SiteHeader: React.FC<{
|
||||
site?: Profile | undefined
|
||||
site?: Profile | undefined | null
|
||||
subscriptions?: Links | null
|
||||
}> = ({ site, subscriptions }) => {
|
||||
const { address } = useAccount()
|
||||
|
|
|
|||
|
|
@ -39,11 +39,11 @@ export default function SettingsDomainsPage() {
|
|||
|
||||
const [hasSet, setHasSet] = useState(false)
|
||||
useEffect(() => {
|
||||
if (site.isSuccess && site.data && !css && !hasSet && subdomain) {
|
||||
if (site.isSuccess && site.data && !css && !hasSet) {
|
||||
setCss(site.data.css || "")
|
||||
setHasSet(true)
|
||||
}
|
||||
}, [site.data, site.isSuccess, css, hasSet, subdomain])
|
||||
}, [site.data, site.isSuccess, css, hasSet])
|
||||
|
||||
const title = "Site Settings"
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ export default function SiteSettingsNavigationPage() {
|
|||
|
||||
const itemsModified = useMemo(() => {
|
||||
if (!site.isSuccess) return false
|
||||
return !equal(items, site.data.navigation)
|
||||
return !equal(items, site.data?.navigation)
|
||||
}, [items, site.data, site.isSuccess])
|
||||
|
||||
const updateItem: UpdateItem = (id, newItem) => {
|
||||
|
|
|
|||
|
|
@ -15,6 +15,9 @@ export const useGetUserSites = (address?: string) => {
|
|||
export const useGetSite = (input: string) => {
|
||||
const unidata = useUnidata()
|
||||
return useQuery(["getSite", input], async () => {
|
||||
if (!input) {
|
||||
return null
|
||||
}
|
||||
return siteModel.getSite(input, unidata)
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue