diff --git a/public/locales/zh/dashboard.json b/public/locales/zh/dashboard.json index 37f1ec9a..3eb9975b 100644 --- a/public/locales/zh/dashboard.json +++ b/public/locales/zh/dashboard.json @@ -175,5 +175,6 @@ "Join xLog's Discord channel": "加入 xLog 的 Discord 频道", "Participate in the development of xLog": "参与 xLog 的开发", "Follow xLog's Twitter": "关注 xLog 的 Twitter", - "Check out the updates of other bloggers": "查看其他博主的更新" + "Check out the updates of other bloggers": "查看其他博主的更新", + "You have already imported them, please enter the post page to create a new post!": "您已经导入了它们,请进入文章页面创建新的文章吧。" } \ No newline at end of file diff --git a/src/models/page.model.ts b/src/models/page.model.ts index 08e793c4..1daa0481 100644 --- a/src/models/page.model.ts +++ b/src/models/page.model.ts @@ -639,3 +639,14 @@ export async function getSummary({ await fetch(`/api/summary?cid=${cid}&lang=${lang || "en"}`) ).text() } + +export async function checkMirror(characterId: string) { + const notes = await indexer.getNotes({ + characterId, + sources: ["xlog"], + tags: ["post", "Mirror.xyz"], + limit: 0, + }) + + return notes.count === 0 +} diff --git a/src/pages/dashboard/[subdomain]/import/mirror.tsx b/src/pages/dashboard/[subdomain]/import/mirror.tsx index 24b8066d..51f5084d 100644 --- a/src/pages/dashboard/[subdomain]/import/mirror.tsx +++ b/src/pages/dashboard/[subdomain]/import/mirror.tsx @@ -14,7 +14,7 @@ import type { NoteMetadata } from "crossbell.js" import { ImportPreview } from "~/components/dashboard/ImportPreview" import { usePostNotes } from "~/queries/page" import { toast } from "react-hot-toast" -import { useGetMirrorXyz } from "~/queries/page" +import { useGetMirrorXyz, useCheckMirror } from "~/queries/page" export const getServerSideProps: GetServerSideProps = serverSidePropsHandler( async (ctx) => { @@ -42,6 +42,7 @@ export default function ImportMarkdownPage() { const mirrorXyz = useGetMirrorXyz({ address: site.data?.metadata?.owner, }) + const checkeMirror = useCheckMirror(site.data?.metadata?.proof) const notes = mirrorXyz?.data?.map((note) => ({ title: note.title, @@ -83,34 +84,42 @@ export default function ImportMarkdownPage() { return ( -
-
-
-
- {t("Preview your Mirror.xyz entries")} + {checkeMirror?.data ? ( + +
+
+
+ {t("Preview your Mirror.xyz entries")} +
+ {notes?.length ? ( + notes?.map((note: NoteMetadata) => ( + + )) + ) : ( +
{t("No entries")}
+ )} +
+
+
- {notes?.length ? ( - notes?.map((note: NoteMetadata) => ( - - )) - ) : ( -
{t("No entries")}
- )} -
-
-
+ + ) : ( +
+ {t( + "You have already imported them, please enter the post page to create a new post!", + )}
- + )} ) } diff --git a/src/queries/page.ts b/src/queries/page.ts index 26634338..9defdb0f 100644 --- a/src/queries/page.ts +++ b/src/queries/page.ts @@ -293,3 +293,12 @@ export function useGetMirrorXyz(input: { address: string }) { }[] }) } + +export function useCheckMirror(characterId?: string) { + return useQuery(["checkMirror", characterId], async () => { + if (!characterId) { + return + } + return pageModel.checkMirror(characterId) + }) +}