From 75c44e7ef39ea09b778178e55c770f65bab5fa44 Mon Sep 17 00:00:00 2001 From: DIYgod Date: Thu, 30 Mar 2023 23:34:41 +0100 Subject: [PATCH] feat: refresh timeout and ai filting i18n --- public/locales/zh/common.json | 5 ++++- src/components/main/MainFeed.tsx | 27 ++++++++++++++++++++++----- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/public/locales/zh/common.json b/public/locales/zh/common.json index db1663ae..049d9c2f 100644 --- a/public/locales/zh/common.json +++ b/public/locales/zh/common.json @@ -69,5 +69,8 @@ "Custom": "自定义", "Mintable": "可铸造", "Comming soon": "即将推出", - "Successfully followed": "嘿!你已经准备好<2>在这里跟上你关注的博主的最新动态了。" + "Successfully followed": "嘿!你已经准备好<2>在这里跟上你关注的博主的最新动态了。", + "Enable AI Filtering": "启用 AI 过滤", + "Filter out possible low-quality content based on AI ratings.": "基于 AI 评分过滤可能质量不佳的内容。", + "Refreshing": "刷新中" } \ No newline at end of file diff --git a/src/components/main/MainFeed.tsx b/src/components/main/MainFeed.tsx index c8b02b5c..1fe48f0f 100644 --- a/src/components/main/MainFeed.tsx +++ b/src/components/main/MainFeed.tsx @@ -12,6 +12,7 @@ import { ExpandedNote } from "~/lib/types" import { useEffect, useState } from "react" import { Switch } from "@headlessui/react" import { setStorage, getStorage } from "~/lib/storage" +import { Tooltip } from "~/components/ui/Tooltip" const Post = ({ post, @@ -128,6 +129,8 @@ const Post = ({ export const MainFeed: React.FC<{ type?: "latest" | "recommend" | "following" }> = ({ type }) => { + const { t } = useTranslation(["common", "site"]) + const currentCharacterId = useAccountState( (s) => s.computed.account?.characterId, ) @@ -140,9 +143,14 @@ 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 ( @@ -155,7 +163,7 @@ export const MainFeed: React.FC<{ className="relative mt-4 w-full text-sm text-center py-4" key={"loading"} > - Loading ... + {t("Loading")} ... } className="space-y-10" @@ -163,7 +171,16 @@ export const MainFeed: React.FC<{ {hasFiltering && (
- Enable AI Filtering + + {t("Enable AI Filtering")} + + + + { @@ -185,11 +202,11 @@ export const MainFeed: React.FC<{
)} - {feed.isRefetching && ( -
Refreshing...
+ {feed.isRefetching && !refreshTimeout && ( +
{t("Refreshing")}...
)} {feed.isLoading ? ( -
Loading...
+
{t("Loading")}...
) : !feed.data?.pages[0]?.count ? ( ) : (