feat: activities ssr
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
NEXT_PUBLIC_APP_NAME=xLog
|
||||
NEXT_PUBLIC_OUR_DOMAIN=localhost:2222
|
||||
NEXT_PUBLIC_SCORE_API_DOMAIN=localhost:2222
|
||||
NEXT_PUBLIC_DISCORD_LINK="https://discord.gg/46VJMMVCuF"
|
||||
NEXT_PUBLIC_TWITTER_LINK="https://twitter.com/_xLog"
|
||||
NEXT_PUBLIC_GITHUB_LINK="https://github.com/Crossbell-Box/xlog"
|
||||
|
||||
+8
-7
@@ -3,11 +3,12 @@
|
||||
40669, 45828, 26375, 49041, 48952, 51408, 51470, 51072, 496, 38034, 47359,
|
||||
33335, 50701, 50161, 470, 50312, 21052, 32022, 274, 77, 50168, 51145, 47328,
|
||||
630, 383, 51383, 723, 51172, 4583, 50472, 32179, 51316, 33210, 45089, 51094,
|
||||
31132, 50140, 37137, 42839, 50114, 51006, 51191, 50843, 46648, 33398, 887,
|
||||
51126, 51197, 32085, 1407, 51154, 51104, 40675, 4381, 43051, 50622, 51056,
|
||||
33483, 19, 50877, 33420, 50094, 49213, 33276, 50351, 42993, 50216, 50132,
|
||||
45763, 50143, 43754, 32168, 500, 47399, 33538, 48951, 33471, 33396, 37223,
|
||||
33458, 39133, 20004, 43625, 42787, 43258, 33462, 47109, 46939, 45701, 33233,
|
||||
37346, 40671, 33870, 33421, 51552, 51585, 48937, 51379, 51460, 51084, 51509,
|
||||
51478, 51639, 48910, 51139, 39329, 51683, 51077, 51374, 49120, 47356
|
||||
31132, 50140, 37137, 42839, 50114, 51006, 51191, 50843, 46648, 887, 51126,
|
||||
51197, 32085, 1407, 51154, 51104, 40675, 4381, 43051, 50622, 51056, 33483, 19,
|
||||
50877, 33420, 50094, 49213, 33276, 50351, 42993, 50216, 50132, 50143, 43754,
|
||||
32168, 500, 47399, 33538, 48951, 33471, 33396, 37223, 33458, 39133, 20004,
|
||||
43625, 42787, 43258, 33462, 47109, 46939, 45701, 33233, 37346, 40671, 33870,
|
||||
33421, 51552, 51585, 48937, 51379, 51460, 51084, 51509, 51478, 51639, 48910,
|
||||
51139, 39329, 51683, 51077, 51374, 49120, 47356, 17096, 50708, 51430, 51935,
|
||||
51756
|
||||
]
|
||||
|
||||
@@ -26,7 +26,8 @@ const Post = ({
|
||||
const date = useDate()
|
||||
|
||||
if (
|
||||
post.metadata?.content?.score?.number &&
|
||||
filtering &&
|
||||
post.metadata?.content?.score?.number !== undefined &&
|
||||
post.metadata.content.score.number <= filtering
|
||||
) {
|
||||
return null
|
||||
@@ -145,14 +146,9 @@ export const MainFeed: React.FC<{
|
||||
const hasFiltering = type === "latest"
|
||||
|
||||
const [aiFiltering, setAiFiltering] = useState(false)
|
||||
const [refreshTimeout, setRefreshTimeout] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
setAiFiltering(getStorage("ai_filtering")?.enabled || false)
|
||||
|
||||
setTimeout(() => {
|
||||
setRefreshTimeout(true)
|
||||
}, 5000)
|
||||
}, [])
|
||||
|
||||
return (
|
||||
@@ -204,9 +200,6 @@ export const MainFeed: React.FC<{
|
||||
</Switch>
|
||||
</div>
|
||||
)}
|
||||
{feed.isRefetching && !refreshTimeout && (
|
||||
<div className="text-center text-zinc-600">{t("Refreshing")}...</div>
|
||||
)}
|
||||
{feed.isLoading ? (
|
||||
<div className="text-center text-zinc-600">{t("Loading")}...</div>
|
||||
) : !feed.data?.pages[0]?.count ? (
|
||||
|
||||
@@ -2,6 +2,7 @@ import { IS_PROD } from "./constants"
|
||||
|
||||
export const APP_NAME = process.env.NEXT_PUBLIC_APP_NAME || "xLog"
|
||||
export const OUR_DOMAIN = process.env.NEXT_PUBLIC_OUR_DOMAIN
|
||||
export const SCORE_API_DOMAIN = process.env.NEXT_PUBLIC_SCORE_API_DOMAIN
|
||||
export const DOCS_DOMAIN = `docs.${OUR_DOMAIN}`
|
||||
export const SITE_URL = `${IS_PROD ? "https" : "http"}://${OUR_DOMAIN}`
|
||||
export const APP_DESCRIPTION =
|
||||
|
||||
@@ -2,8 +2,7 @@ import { ExpandedNote } from "~/lib/types"
|
||||
import { indexer } from "@crossbell/indexer"
|
||||
import { toCid } from "~/lib/ipfs-parser"
|
||||
import { createClient } from "@urql/core"
|
||||
import axios from "axios"
|
||||
import { NoteEntity } from "crossbell.js"
|
||||
import { OUR_DOMAIN, SCORE_API_DOMAIN } from "~/lib/env"
|
||||
|
||||
const expandPage = async (
|
||||
page: ExpandedNote,
|
||||
@@ -41,7 +40,11 @@ const expandPage = async (
|
||||
try {
|
||||
const score = (
|
||||
await (
|
||||
await fetch(`/api/score?cid=${toCid(page.metadata?.uri || "")}`)
|
||||
await fetch(
|
||||
`${SCORE_API_DOMAIN || OUR_DOMAIN}/api/score?cid=${toCid(
|
||||
page.metadata?.uri || "",
|
||||
)}`,
|
||||
)
|
||||
).json()
|
||||
).data
|
||||
page.metadata.content.score = score
|
||||
|
||||
@@ -11,10 +11,17 @@ import { languageDetector } from "~/lib/language-detector"
|
||||
import { MainFeed } from "~/components/main/MainFeed"
|
||||
import { Tabs } from "~/components/ui/Tabs"
|
||||
import { MainSidebar } from "~/components/main/MainSidebar"
|
||||
import { prefetchGetFeed } from "~/queries/home.server"
|
||||
|
||||
export const getServerSideProps: GetServerSideProps = async (ctx) => {
|
||||
const queryClient = new QueryClient()
|
||||
await prefetchGetSites(showcase, queryClient)
|
||||
await prefetchGetFeed(
|
||||
{
|
||||
type: "latest",
|
||||
},
|
||||
queryClient,
|
||||
)
|
||||
|
||||
return {
|
||||
props: {
|
||||
@@ -23,7 +30,7 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => {
|
||||
"index",
|
||||
"dashboard",
|
||||
])),
|
||||
dehydratedState: dehydrate(queryClient),
|
||||
dehydratedState: JSON.parse(JSON.stringify(dehydrate(queryClient))),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import { QueryClient } from "@tanstack/react-query"
|
||||
import { cacheGet } from "~/lib/redis.server"
|
||||
|
||||
import * as homeModel from "~/models/home.model"
|
||||
|
||||
export const prefetchGetFeed = async (
|
||||
data: {
|
||||
type?: "latest" | "recommend" | "following" | "topic"
|
||||
characterId?: number
|
||||
limit?: number
|
||||
noteIds?: string[]
|
||||
},
|
||||
queryClient: QueryClient,
|
||||
) => {
|
||||
const key = ["getFeed", data]
|
||||
await queryClient.prefetchInfiniteQuery({
|
||||
queryKey: ["getFeed", data],
|
||||
queryFn: async ({ pageParam }) => {
|
||||
return cacheGet({
|
||||
key,
|
||||
getValueFun: () =>
|
||||
homeModel.getFeed({
|
||||
...data,
|
||||
cursor: pageParam,
|
||||
}),
|
||||
})
|
||||
},
|
||||
getNextPageParam: (lastPage) => lastPage?.cursor || undefined,
|
||||
})
|
||||
}
|
||||
@@ -83,7 +83,6 @@
|
||||
"51356-2",
|
||||
"51356-4",
|
||||
"51494-14",
|
||||
"51539-3",
|
||||
"51683-30",
|
||||
"51683-33",
|
||||
"51683-49",
|
||||
|
||||
Reference in New Issue
Block a user