fix: hydration error

This commit is contained in:
DIYgod
2023-07-13 23:56:42 +01:00
parent 4721633bb9
commit eb6af22e60
2 changed files with 50 additions and 49 deletions
+7 -4
View File
@@ -24,7 +24,7 @@ import { getSiteLink } from "~/lib/helpers"
import { useTranslation } from "~/lib/i18n/client"
import { getStorage, setStorage } from "~/lib/storage"
import { ExpandedNote } from "~/lib/types"
import { cn, getStringLength, isServerSide } from "~/lib/utils"
import { cn, getStringLength } from "~/lib/utils"
import type { FeedType, SearchType } from "~/models/home.model"
import { useGetFeed } from "~/queries/home"
@@ -341,6 +341,11 @@ export const HomeFeed = ({ type }: { type?: FeedType }) => {
}
}, [feed.data?.pages, aiFiltering])
const [isMounted, setIsMounted] = useState(false)
useEffect(() => {
setIsMounted(true)
}, [])
return (
<>
<div className="space-y-10">
@@ -412,9 +417,7 @@ export const HomeFeed = ({ type }: { type?: FeedType }) => {
}}
></VirtuosoGrid>
{feed.isFetching && feed.hasNextPage && !isServerSide() && (
<Loader />
)}
{feed.isFetching && feed.hasNextPage && isMounted && <Loader />}
</div>
)}
</div>
+43 -45
View File
@@ -16,52 +16,50 @@ export async function HomeSidebar({ hideSearch }: { hideSearch?: boolean }) {
return (
<div className="w-80 pl-10 hidden lg:block space-y-10">
{!hideSearch && <SearchInput />}
<div className="text-center">
<div className="text-zinc-700 space-y-3">
<p className="font-bold text-lg">{t("Suggested creators for you")}</p>
<FollowAllButton
characterIds={showcaseSites
?.map((s: { characterId?: string }) => s.characterId)
.filter(Boolean)
.map(Number)}
siteIds={showcaseSites?.map((s: { handle: string }) => s.handle)}
/>
<ShowMoreContainer>
<>
{showcaseSites?.map((site) => (
<li className="flex align-middle" key={site.handle}>
<UniLink
href={getSiteLink({
subdomain: site.handle,
})}
className="inline-flex align-middle w-full"
>
<CharacterFloatCard siteId={site.handle}>
<span className="w-10 h-10 inline-block">
<Avatar
cid={site?.characterId}
images={site?.metadata?.content?.avatars || []}
size={40}
name={site?.metadata?.content?.name}
></Avatar>
</span>
</CharacterFloatCard>
<span className="ml-3 min-w-0 flex-1 justify-center inline-flex flex-col">
<span className="truncate w-full inline-block font-medium">
{site?.metadata?.content?.name}
</span>
{site?.metadata?.content?.bio && (
<span className="text-gray-500 text-xs truncate w-full inline-block mt-1">
{site.metadata.content?.bio}
</span>
)}
<div className="text-center text-zinc-700 space-y-3">
<p className="font-bold text-lg">{t("Suggested creators for you")}</p>
<FollowAllButton
characterIds={showcaseSites
?.map((s: { characterId?: string }) => s.characterId)
.filter(Boolean)
.map(Number)}
siteIds={showcaseSites?.map((s: { handle: string }) => s.handle)}
/>
<ShowMoreContainer>
<>
{showcaseSites?.map((site) => (
<li className="flex align-middle" key={site.handle}>
<UniLink
href={getSiteLink({
subdomain: site.handle,
})}
className="inline-flex align-middle w-full"
>
<CharacterFloatCard siteId={site.handle}>
<span className="w-10 h-10 inline-block">
<Avatar
cid={site?.characterId}
images={site?.metadata?.content?.avatars || []}
size={40}
name={site?.metadata?.content?.name}
></Avatar>
</span>
</UniLink>
</li>
))}
</>
</ShowMoreContainer>
</div>
</CharacterFloatCard>
<span className="ml-3 min-w-0 flex-1 justify-center inline-flex flex-col">
<span className="truncate w-full inline-block font-medium">
{site?.metadata?.content?.name}
</span>
{site?.metadata?.content?.bio && (
<span className="text-gray-500 text-xs truncate w-full inline-block mt-1">
{site.metadata.content?.bio}
</span>
)}
</span>
</UniLink>
</li>
))}
</>
</ShowMoreContainer>
</div>
</div>
)