diff --git a/.env.example b/.env.example
index 128994db..f4d15692 100644
--- a/.env.example
+++ b/.env.example
@@ -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"
diff --git a/showcase.json b/showcase.json
index b52cbf47..6ebee015 100644
--- a/showcase.json
+++ b/showcase.json
@@ -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
]
diff --git a/src/components/main/MainFeed.tsx b/src/components/main/MainFeed.tsx
index 81c9117a..460d70d3 100644
--- a/src/components/main/MainFeed.tsx
+++ b/src/components/main/MainFeed.tsx
@@ -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<{
)}
- {feed.isRefetching && !refreshTimeout && (
-
{t("Refreshing")}...
- )}
{feed.isLoading ? (
{t("Loading")}...
) : !feed.data?.pages[0]?.count ? (
diff --git a/src/lib/env.ts b/src/lib/env.ts
index 4dbee0ea..c976f180 100644
--- a/src/lib/env.ts
+++ b/src/lib/env.ts
@@ -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 =
diff --git a/src/models/home.model.ts b/src/models/home.model.ts
index f7631cc8..7e56f168 100644
--- a/src/models/home.model.ts
+++ b/src/models/home.model.ts
@@ -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
diff --git a/src/pages/activities.tsx b/src/pages/activities.tsx
index 4f1094ed..2e2395a6 100644
--- a/src/pages/activities.tsx
+++ b/src/pages/activities.tsx
@@ -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))),
},
}
}
diff --git a/src/queries/home.server.ts b/src/queries/home.server.ts
new file mode 100644
index 00000000..a1a8f37d
--- /dev/null
+++ b/src/queries/home.server.ts
@@ -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,
+ })
+}
diff --git a/topics.json b/topics.json
index 9937c832..95896b9d 100644
--- a/topics.json
+++ b/topics.json
@@ -83,7 +83,6 @@
"51356-2",
"51356-4",
"51494-14",
- "51539-3",
"51683-30",
"51683-33",
"51683-49",