Merge branch 'dev' into fix-240
This commit is contained in:
+4
-4
@@ -7,8 +7,8 @@
|
||||
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, 6558, 49392, 52186, 52055, 52282, 52270, 5825, 51351, 52233
|
||||
43625, 42787, 43258, 33462, 47109, 46939, 45701, 33233, 37346, 40671, 51552,
|
||||
51585, 48937, 51379, 51460, 51084, 51509, 51478, 51639, 48910, 51139, 39329,
|
||||
51683, 51077, 51374, 49120, 47356, 17096, 50708, 51430, 51935, 51756, 6558,
|
||||
49392, 52186, 52055, 52282, 52270, 5825, 51351, 52233, 51308
|
||||
]
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
[
|
||||
{
|
||||
"name": "xLog contributor",
|
||||
"link": "https://github.com/Crossbell-Box/xLog/graphs/contributors",
|
||||
"list": [
|
||||
10, 30, 12, 32022, 32179, 45, 19, 4583, 4381, 32168, 33446, 33492, 52055,
|
||||
153, 50143, 51470
|
||||
]
|
||||
}
|
||||
]
|
||||
+12
-3
@@ -52,7 +52,11 @@
|
||||
"52270-127",
|
||||
"52258-1",
|
||||
"52319-1",
|
||||
"52299-1"
|
||||
"52299-1",
|
||||
"52220-2",
|
||||
"52387-1",
|
||||
"52314-1",
|
||||
"52336-2"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -126,7 +130,11 @@
|
||||
"50622-16",
|
||||
"50622-15",
|
||||
"33492-5",
|
||||
"52242-1"
|
||||
"52242-1",
|
||||
"52388-2",
|
||||
"52242-16",
|
||||
"51084-7",
|
||||
"50708-12"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -276,7 +284,8 @@
|
||||
"51124-29",
|
||||
"31132-7",
|
||||
"31132-5",
|
||||
"48910-9"
|
||||
"48910-9",
|
||||
"48910-11"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
+20
-20
@@ -35,41 +35,41 @@
|
||||
"@crossbell/notification": "0.0.58",
|
||||
"@crossbell/ui": "0.0.58",
|
||||
"@crossbell/util-hooks": "0.0.58",
|
||||
"@dqbd/tiktoken": "^1.0.2",
|
||||
"@dqbd/tiktoken": "^1.0.3",
|
||||
"@emoji-mart/data": "1.1.2",
|
||||
"@emoji-mart/react": "1.1.1",
|
||||
"@floating-ui/react": "^0.22.2",
|
||||
"@floating-ui/react": "^0.22.3",
|
||||
"@headlessui/react": "1.7.13",
|
||||
"@heroicons/react": "2.0.17",
|
||||
"@iconify-json/mingcute": "^1.1.5",
|
||||
"@mantine/core": "^6.0.5",
|
||||
"@mantine/core": "^6.0.6",
|
||||
"@monaco-editor/react": "4.4.6",
|
||||
"@prisma/client": "^4.12.0",
|
||||
"@tanstack/react-query": "4.28.0",
|
||||
"@tanstack/react-query-devtools": "4.28.0",
|
||||
"@tanstack/react-query-devtools": "4.29.0",
|
||||
"@tanstack/react-query-persist-client": "4.28.0",
|
||||
"@uiw/codemirror-extensions-events": "4.19.11",
|
||||
"@uiw/react-codemirror": "4.19.11",
|
||||
"@urql/core": "3.2.2",
|
||||
"axios": "1.3.4",
|
||||
"@urql/core": "4.0.3",
|
||||
"axios": "1.3.5",
|
||||
"canvas-confetti": "^1.6.0",
|
||||
"chroma-js": "^2.4.2",
|
||||
"clsx": "1.2.1",
|
||||
"crossbell.js": "0.19.5",
|
||||
"crossbell.js": "0.19.7",
|
||||
"dayjs": "1.11.7",
|
||||
"dotenv": "16.0.3",
|
||||
"emoji-mart": "5.5.2",
|
||||
"fast-average-color": "^9.3.0",
|
||||
"fast-deep-equal": "3.1.3",
|
||||
"i18next": "^22.4.13",
|
||||
"i18next": "^22.4.14",
|
||||
"idb-keyval": "6.2.0",
|
||||
"immer": "9.0.21",
|
||||
"ioredis": "5.3.1",
|
||||
"js-yaml": "4.1.0",
|
||||
"jsonfeed-to-rss": "^3.0.6",
|
||||
"langchain": "^0.0.44",
|
||||
"langchain": "^0.0.49",
|
||||
"lottie-react": "^2.4.0",
|
||||
"mdast-util-to-string": "3.1.1",
|
||||
"mdast-util-to-string": "3.2.0",
|
||||
"mdast-util-toc": "6.1.1",
|
||||
"nanoid": "4.0.2",
|
||||
"next": "13.2.4",
|
||||
@@ -83,7 +83,7 @@
|
||||
"react-hot-toast": "2.4.0",
|
||||
"react-i18next": "^12.2.0",
|
||||
"react-infinite-scroller": "1.2.6",
|
||||
"react-parallax-tilt": "^1.7.120",
|
||||
"react-parallax-tilt": "^1.7.125",
|
||||
"react-scroll": "1.8.9",
|
||||
"react-sortablejs": "6.1.4",
|
||||
"refractor": "4.8.1",
|
||||
@@ -107,28 +107,28 @@
|
||||
"remark-stringify": "10.0.2",
|
||||
"sharp": "0.32.0",
|
||||
"sortablejs": "1.15.0",
|
||||
"tailwind-merge": "^1.11.0",
|
||||
"tailwind-merge": "^1.12.0",
|
||||
"tailwindcss-animate": "^1.0.5",
|
||||
"unidata.js": "0.7.17",
|
||||
"unidata.js": "0.7.18",
|
||||
"unified": "10.1.2",
|
||||
"unist-builder": "3.0.1",
|
||||
"unist-util-visit": "4.1.2",
|
||||
"use-onclickoutside": "0.4.1",
|
||||
"uuid": "9.0.0",
|
||||
"wagmi": "0.12.8"
|
||||
"wagmi": "0.12.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@next/bundle-analyzer": "13.2.4",
|
||||
"@playwright/test": "1.32.1",
|
||||
"@next/bundle-analyzer": "13.3.0",
|
||||
"@playwright/test": "1.32.2",
|
||||
"@types/canvas-confetti": "^1.6.0",
|
||||
"@types/chroma-js": "^2.4.0",
|
||||
"@types/cookie": "0.5.1",
|
||||
"@types/hast": "2.3.4",
|
||||
"@types/js-yaml": "4.0.5",
|
||||
"@types/mjml": "4.7.0",
|
||||
"@types/mjml": "4.7.1",
|
||||
"@types/node": "18.15.11",
|
||||
"@types/prismjs": "1.26.0",
|
||||
"@types/react": "18.0.31",
|
||||
"@types/react": "18.0.33",
|
||||
"@types/react-dom": "18.0.11",
|
||||
"@types/react-infinite-scroller": "1.2.3",
|
||||
"@types/react-scroll": "1.8.6",
|
||||
@@ -140,10 +140,10 @@
|
||||
"autoprefixer": "10.4.14",
|
||||
"babel-loader": "^9.1.2",
|
||||
"cross-spawn": "7.0.3",
|
||||
"esbuild": "0.17.14",
|
||||
"esbuild": "0.17.15",
|
||||
"esbuild-register": "3.4.2",
|
||||
"eslint": "8.37.0",
|
||||
"eslint-config-next": "13.2.4",
|
||||
"eslint-config-next": "13.3.0",
|
||||
"husky": "8.0.3",
|
||||
"lint-staged": "13.2.0",
|
||||
"next-pwa": "^5.6.0",
|
||||
|
||||
Generated
+613
-544
File diff suppressed because it is too large
Load Diff
@@ -28,6 +28,9 @@
|
||||
"Submit": "提交",
|
||||
"Reply": "回复",
|
||||
"Cancel Reply": "取消回复",
|
||||
"Edit": "编辑",
|
||||
"Cancel Edit": "取消编辑",
|
||||
"Confirm Modification": "确认修改",
|
||||
"ago": "{{time}}前",
|
||||
"joined ago": "{{time}}前加入",
|
||||
"obtained ago": "{{time}}前获得",
|
||||
|
||||
@@ -7,6 +7,7 @@ import type { Profile } from "~/lib/types"
|
||||
import { cn } from "~/lib/utils"
|
||||
import { useDate } from "~/hooks/useDate"
|
||||
import { useTranslation } from "next-i18next"
|
||||
import { Titles } from "~/components/common/Titles"
|
||||
|
||||
export const CharacterCard: React.FC<{
|
||||
siteId?: string
|
||||
@@ -71,11 +72,12 @@ export const CharacterCard: React.FC<{
|
||||
/>
|
||||
)}
|
||||
</span>
|
||||
<span className="block">
|
||||
<span className="flex items-center space-x-1">
|
||||
<span className="font-bold text-base text-zinc-800">
|
||||
{site?.name}
|
||||
</span>
|
||||
<span className="ml-1 text-gray-600">@{site?.username}</span>
|
||||
<Titles characterId={+(site.metadata?.proof || "")} />
|
||||
<span className="text-gray-600">@{site?.username}</span>
|
||||
</span>
|
||||
{site?.description && (
|
||||
<span
|
||||
|
||||
@@ -6,20 +6,25 @@ import { Button } from "~/components/ui/Button"
|
||||
import { useForm } from "react-hook-form"
|
||||
import { useAccountState } from "@crossbell/connect-kit"
|
||||
import { useState, useEffect } from "react"
|
||||
import { useCommentPage } from "~/queries/page"
|
||||
import { useCommentPage, useUpdateComment } from "~/queries/page"
|
||||
import { useRouter } from "next/router"
|
||||
import { EmojiPicker } from "./EmojiPicker"
|
||||
import { Popover } from "@headlessui/react"
|
||||
import { useTranslation } from "next-i18next"
|
||||
import { NoteEntity, CharacterEntity } from "crossbell.js"
|
||||
|
||||
export const CommentInput: React.FC<{
|
||||
pageId?: string
|
||||
originalId?: string
|
||||
onSubmitted?: () => void
|
||||
}> = ({ pageId, originalId, onSubmitted }) => {
|
||||
comment?: NoteEntity & {
|
||||
character?: CharacterEntity | null
|
||||
}
|
||||
}> = ({ pageId, originalId, onSubmitted, comment }) => {
|
||||
const account = useAccountState((s) => s.computed.account)
|
||||
const userSites = useAccountSites()
|
||||
const commentPage = useCommentPage()
|
||||
const updateComment = useUpdateComment()
|
||||
const router = useRouter()
|
||||
const [viewer, setViewer] = useState<Profile | null>(null)
|
||||
const { t } = useTranslation(["common", "site"])
|
||||
@@ -32,27 +37,38 @@ export const CommentInput: React.FC<{
|
||||
|
||||
const form = useForm({
|
||||
defaultValues: {
|
||||
content: "",
|
||||
content: comment?.metadata?.content?.content || "",
|
||||
},
|
||||
})
|
||||
|
||||
const handleSubmit = form.handleSubmit(async (values) => {
|
||||
if (pageId) {
|
||||
commentPage.mutate({
|
||||
pageId: pageId,
|
||||
content: values.content,
|
||||
externalUrl: window.location.href,
|
||||
originalId: originalId,
|
||||
})
|
||||
if (pageId && values.content) {
|
||||
if (comment) {
|
||||
updateComment.mutate({
|
||||
pageId,
|
||||
content: values.content,
|
||||
externalUrl: window.location.href,
|
||||
originalId,
|
||||
characterId: comment.characterId,
|
||||
noteId: comment.noteId,
|
||||
})
|
||||
} else {
|
||||
commentPage.mutate({
|
||||
pageId,
|
||||
content: values.content,
|
||||
externalUrl: window.location.href,
|
||||
originalId,
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
if (commentPage.isSuccess) {
|
||||
if (commentPage.isSuccess || updateComment.isSuccess) {
|
||||
form.reset()
|
||||
onSubmitted?.()
|
||||
}
|
||||
}, [commentPage.isSuccess, form, onSubmitted])
|
||||
}, [commentPage.isSuccess, updateComment.isSuccess, form, onSubmitted])
|
||||
|
||||
return (
|
||||
<div className="xlog-comment-input flex">
|
||||
@@ -104,12 +120,18 @@ export const CommentInput: React.FC<{
|
||||
</Popover>
|
||||
<Button
|
||||
type="submit"
|
||||
isLoading={userSites.isLoading || commentPage.isLoading}
|
||||
isLoading={
|
||||
userSites.isLoading ||
|
||||
commentPage.isLoading ||
|
||||
updateComment.isLoading
|
||||
}
|
||||
>
|
||||
{t(
|
||||
account
|
||||
? userSites.isSuccess && !userSites.data?.length
|
||||
? "Create Character"
|
||||
: comment
|
||||
? "Confirm Modification"
|
||||
: "Submit"
|
||||
: "Connect",
|
||||
)}
|
||||
|
||||
@@ -12,6 +12,8 @@ import { CommentInput } from "~/components/common/CommentInput"
|
||||
import { CharacterFloatCard } from "~/components/common/CharacterFloatCard"
|
||||
import { useTranslation } from "next-i18next"
|
||||
import { useDate } from "~/hooks/useDate"
|
||||
import { useAccountState } from "@crossbell/connect-kit"
|
||||
import { Titles } from "~/components/common/Titles"
|
||||
|
||||
export const CommentItem: React.FC<{
|
||||
comment: NoteEntity & {
|
||||
@@ -21,9 +23,13 @@ export const CommentItem: React.FC<{
|
||||
depth: number
|
||||
}> = ({ comment, originalId, depth }) => {
|
||||
const [replyOpen, setReplyOpen] = useState(false)
|
||||
const [editOpen, setEditOpen] = useState(false)
|
||||
|
||||
const { t } = useTranslation("common")
|
||||
const date = useDate()
|
||||
|
||||
const account = useAccountState(({ computed }) => computed.account)
|
||||
|
||||
if (!comment.metadata?.content?.content) {
|
||||
return null
|
||||
}
|
||||
@@ -65,6 +71,7 @@ export const CommentItem: React.FC<{
|
||||
>
|
||||
{comment?.character?.metadata?.content?.name}
|
||||
</UniLink>
|
||||
<Titles characterId={comment.characterId} />
|
||||
<span>·</span>
|
||||
<time dateTime={date.formatToISO(comment?.createdAt)}>
|
||||
{t("ago", {
|
||||
@@ -95,7 +102,7 @@ export const CommentItem: React.FC<{
|
||||
/>
|
||||
{depth < 2 && (
|
||||
<Button
|
||||
className="text-gray-500 text-[13px] ml-2 mt-[-1px]"
|
||||
className="text-gray-500 text-[13px] ml-1 mt-[-1px]"
|
||||
variant="text"
|
||||
onClick={() => setReplyOpen(!replyOpen)}
|
||||
>
|
||||
@@ -105,6 +112,16 @@ export const CommentItem: React.FC<{
|
||||
</span>
|
||||
</Button>
|
||||
)}
|
||||
{comment.characterId === account?.characterId && (
|
||||
<Button
|
||||
className="text-gray-500 text-[13px] mt-[-1px]"
|
||||
variant="text"
|
||||
onClick={() => setEditOpen(!editOpen)}
|
||||
>
|
||||
<i className="i-mingcute:edit-line mx-1" />{" "}
|
||||
{t(`${editOpen ? "Cancel " : ""}Edit`)}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
{replyOpen && (
|
||||
<div className="pt-6">
|
||||
@@ -115,6 +132,16 @@ export const CommentItem: React.FC<{
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
{editOpen && (
|
||||
<div className="pt-6">
|
||||
<CommentInput
|
||||
originalId={originalId}
|
||||
pageId={`${comment.characterId}-${comment.noteId}`}
|
||||
onSubmitted={() => setEditOpen(false)}
|
||||
comment={comment}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
{(comment as any)?.fromNotes?.list?.length > 0 && (
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
import { cn } from "~/lib/utils"
|
||||
import data from "../../../data/titles.json"
|
||||
import { Tooltip } from "../ui/Tooltip"
|
||||
import { UniLink } from "../ui/UniLink"
|
||||
|
||||
const icons: {
|
||||
[key: string]: {
|
||||
bg: string
|
||||
icon: string
|
||||
}
|
||||
} = {
|
||||
"xLog contributor": {
|
||||
bg: "bg-zinc-700 text-white",
|
||||
icon: "i-mingcute:terminal-line",
|
||||
},
|
||||
}
|
||||
|
||||
export const Titles: React.FC<{
|
||||
characterId?: number
|
||||
}> = ({ characterId }) => {
|
||||
if (!characterId) {
|
||||
return null
|
||||
}
|
||||
|
||||
const list = data.filter((title) => title.list.includes(characterId))
|
||||
|
||||
if (!list.length) {
|
||||
return null
|
||||
}
|
||||
|
||||
return (
|
||||
<span className="inline-flex">
|
||||
{list.map((title) => (
|
||||
<Tooltip
|
||||
key={title.name}
|
||||
label={title.name}
|
||||
childrenClassName={cn(
|
||||
icons[title.name].bg,
|
||||
"inline-flex p-[1px] rounded-sm",
|
||||
)}
|
||||
>
|
||||
<UniLink href={title.link} className="inline-flex">
|
||||
<i className={cn(icons[title.name].icon, "text-[10px]")} />
|
||||
</UniLink>
|
||||
</Tooltip>
|
||||
))}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import { useEffect, useState } from "react"
|
||||
import { Switch } from "@headlessui/react"
|
||||
import { setStorage, getStorage } from "~/lib/storage"
|
||||
import { Tooltip } from "~/components/ui/Tooltip"
|
||||
import { Titles } from "~/components/common/Titles"
|
||||
|
||||
const Post = ({
|
||||
post,
|
||||
@@ -56,6 +57,7 @@ const Post = ({
|
||||
</span>
|
||||
</div>
|
||||
</CharacterFloatCard>
|
||||
<Titles characterId={post.characterId} />
|
||||
<span className="text-zinc-400">·</span>
|
||||
<time
|
||||
dateTime={date.formatToISO(post.createdAt)}
|
||||
|
||||
@@ -13,6 +13,7 @@ import { useTranslation } from "next-i18next"
|
||||
import { Logo } from "~/components/common/Logo"
|
||||
import { useRouter } from "next/router"
|
||||
import { cn } from "~/lib/utils"
|
||||
import { Image } from "../ui/Image"
|
||||
|
||||
const tabs = [
|
||||
{
|
||||
@@ -24,7 +25,13 @@ const tabs = [
|
||||
link: "/activities",
|
||||
},
|
||||
{
|
||||
name: "Source Code",
|
||||
name: (
|
||||
<Image
|
||||
className="no-optimization w-24"
|
||||
alt="github stars"
|
||||
src="https://img.shields.io/github/stars/Crossbell-Box/xLog?color=white&label=Stars&logo=github&style=social"
|
||||
/>
|
||||
),
|
||||
link: GITHUB_LINK,
|
||||
},
|
||||
]
|
||||
@@ -66,10 +73,10 @@ export function MainLayout({
|
||||
"text-accent": router.pathname === tab.link,
|
||||
},
|
||||
)}
|
||||
key={tab.name}
|
||||
key={tab.link}
|
||||
href={tab.link}
|
||||
>
|
||||
{t(tab.name)}
|
||||
{typeof tab.name === "string" ? t(tab.name) : tab.name}
|
||||
</UniLink>
|
||||
))}
|
||||
<ConnectButton size="base" variantColor="black" />
|
||||
|
||||
@@ -16,7 +16,6 @@ export const Image: React.FC<
|
||||
src = toIPFS(src)
|
||||
const [paddingTop, setPaddingTop] = React.useState("0")
|
||||
const [autoWidth, setAutoWidth] = React.useState(0)
|
||||
const autoSize = !width && !height && !fill
|
||||
const noOptimization = className?.includes("no-optimization")
|
||||
|
||||
if (!src.startsWith("/assets/")) {
|
||||
@@ -27,6 +26,17 @@ export const Image: React.FC<
|
||||
}
|
||||
}
|
||||
|
||||
if (!noOptimization) {
|
||||
if (width) {
|
||||
width = +width
|
||||
}
|
||||
if (height) {
|
||||
height = +height
|
||||
}
|
||||
}
|
||||
|
||||
const autoSize = !width && !height && !fill
|
||||
|
||||
return noOptimization ? (
|
||||
// eslint-disable-next-line @next/next/no-img-element
|
||||
<img
|
||||
|
||||
@@ -21,6 +21,7 @@ interface Props {
|
||||
children: JSX.Element
|
||||
className?: string
|
||||
inline?: boolean
|
||||
childrenClassName?: string
|
||||
}
|
||||
|
||||
export const Tooltip = ({
|
||||
@@ -28,6 +29,7 @@ export const Tooltip = ({
|
||||
label,
|
||||
placement = "top",
|
||||
className,
|
||||
childrenClassName,
|
||||
inline,
|
||||
}: Props) => {
|
||||
const [open, setOpen] = useState(false)
|
||||
@@ -56,7 +58,11 @@ export const Tooltip = ({
|
||||
<div
|
||||
ref={refs.setReference}
|
||||
{...getReferenceProps()}
|
||||
className={cn("items-center", inline ? "inline-flex" : "flex")}
|
||||
className={cn(
|
||||
"items-center",
|
||||
inline ? "inline-flex" : "flex",
|
||||
childrenClassName,
|
||||
)}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
|
||||
@@ -17,39 +17,12 @@ const scheme = {
|
||||
],
|
||||
attributes: {
|
||||
...defaultSchema.attributes,
|
||||
div: [...(defaultSchema.attributes?.div || []), "className", "style", "id"],
|
||||
img: [
|
||||
...(defaultSchema.attributes?.img || []),
|
||||
"className",
|
||||
"style",
|
||||
"id",
|
||||
"width",
|
||||
"height",
|
||||
],
|
||||
code: ["className"],
|
||||
"*": [...(defaultSchema.attributes?.["*"] || []), "className", "style"],
|
||||
blockquote: allowedBlockquoteAttrs,
|
||||
video: [
|
||||
"className",
|
||||
"src",
|
||||
"controls",
|
||||
"loop",
|
||||
"muted",
|
||||
"autoplay",
|
||||
"playsinline",
|
||||
],
|
||||
audio: ["className", "src", "controls", "loop", "muted", "autoplay"],
|
||||
video: ["src", "controls", "loop", "muted", "autoPlay", "playsInline"],
|
||||
audio: ["src", "controls", "loop", "muted", "autoPlay"],
|
||||
source: ["src", "type"],
|
||||
iframe: [
|
||||
"className",
|
||||
"src",
|
||||
"allowFullScreen",
|
||||
"frameborder",
|
||||
"width",
|
||||
"height",
|
||||
"allow",
|
||||
"style",
|
||||
],
|
||||
span: ["className", "style"],
|
||||
iframe: ["src", "allowFullScreen", "frameborder", "allow"],
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ExpandedNote } from "~/lib/types"
|
||||
import { indexer } from "@crossbell/indexer"
|
||||
import { toCid } from "~/lib/ipfs-parser"
|
||||
import { createClient } from "@urql/core"
|
||||
import { createClient, cacheExchange, fetchExchange } from "@urql/core"
|
||||
import { SITE_URL, SCORE_API_DOMAIN } from "~/lib/env"
|
||||
|
||||
const expandPage = async (
|
||||
@@ -136,6 +136,7 @@ export async function getFeed({
|
||||
}
|
||||
const client = createClient({
|
||||
url: "https://indexer.crossbell.io/v1/graphql",
|
||||
exchanges: [cacheExchange, fetchExchange],
|
||||
})
|
||||
|
||||
const orString = noteIds
|
||||
|
||||
@@ -567,6 +567,32 @@ export async function getComments({
|
||||
return res
|
||||
}
|
||||
|
||||
export async function updateComment(
|
||||
{
|
||||
pageId,
|
||||
content,
|
||||
externalUrl,
|
||||
originalId,
|
||||
characterId,
|
||||
noteId,
|
||||
}: {
|
||||
pageId: string
|
||||
content: string
|
||||
externalUrl: string
|
||||
originalId?: string
|
||||
characterId: number
|
||||
noteId: number
|
||||
},
|
||||
contract: Contract,
|
||||
) {
|
||||
return contract.setNoteMetadata(characterId, noteId, {
|
||||
content,
|
||||
external_urls: [externalUrl],
|
||||
tags: ["comment"],
|
||||
sources: ["xlog"],
|
||||
})
|
||||
}
|
||||
|
||||
export function parsePageId(pageId: string) {
|
||||
const [characterId, noteId] = pageId.split("-").map(Number)
|
||||
|
||||
|
||||
+30
-14
@@ -4,11 +4,11 @@ import unidata from "~/queries/unidata.server"
|
||||
import { toGateway } from "~/lib/ipfs-parser"
|
||||
import type Unidata from "unidata.js"
|
||||
import type { Profiles as UniProfiles } from "unidata.js"
|
||||
import { createClient } from "@urql/core"
|
||||
import axios from "axios"
|
||||
import { createClient, cacheExchange, fetchExchange } from "@urql/core"
|
||||
import { Indexer } from "crossbell.js"
|
||||
import { CharacterOperatorPermission } from "crossbell.js"
|
||||
import type { useContract } from "@crossbell/contract"
|
||||
import dayjs from "dayjs"
|
||||
|
||||
type Contract = ReturnType<typeof useContract>
|
||||
|
||||
@@ -134,23 +134,25 @@ export const getSite = async (input: string, customUnidata?: Unidata) => {
|
||||
export const getSites = async (input: number[]) => {
|
||||
const client = createClient({
|
||||
url: "https://indexer.crossbell.io/v1/graphql",
|
||||
exchanges: [cacheExchange, fetchExchange],
|
||||
})
|
||||
const oneMonthAgo = dayjs().subtract(15, "day").toISOString()
|
||||
const result = await client
|
||||
.query(
|
||||
`
|
||||
query getCharacters($identities: [Int!], $limit: Int) {
|
||||
characters( where: { characterId: { in: $identities } }, orderBy: [{ updatedAt: desc }], take: $limit ) {
|
||||
handle
|
||||
updatedAt
|
||||
characterId
|
||||
notes {
|
||||
updatedAt
|
||||
}
|
||||
metadata {
|
||||
uri
|
||||
content
|
||||
}
|
||||
}
|
||||
notes( where: { characterId: { in: $identities }, createdAt: { gt: "${oneMonthAgo}" }, metadata: { is: { content: { path: "sources", array_contains: "xlog" } } } }, orderBy: [{ updatedAt: desc }] ) {
|
||||
characterId
|
||||
createdAt
|
||||
}
|
||||
}`,
|
||||
{
|
||||
identities: input,
|
||||
@@ -171,18 +173,32 @@ export const getSites = async (input: number[]) => {
|
||||
site.metadata?.content?.attributes?.find(
|
||||
(a: any) => a.trait_type === "xlog_custom_domain",
|
||||
)?.value || ""
|
||||
|
||||
site.updatedAt = [...site.notes, site]
|
||||
.map((i) => i.updatedAt)
|
||||
.sort()
|
||||
.pop()
|
||||
})
|
||||
|
||||
result.data?.characters?.sort((a: any, b: any) => {
|
||||
return b.updatedAt > a.updatedAt ? 1 : -1
|
||||
const createdAts: {
|
||||
[key: string]: string
|
||||
} = {}
|
||||
result.data?.notes.forEach((note: any) => {
|
||||
if (!createdAts[note.characterId + ""]) {
|
||||
createdAts[note.characterId + ""] = note.createdAt
|
||||
}
|
||||
})
|
||||
const list = Object.keys(createdAts)
|
||||
.map((characterId: string) => {
|
||||
const character = result.data?.characters.find(
|
||||
(c: any) => c.characterId === characterId,
|
||||
)
|
||||
|
||||
return result.data?.characters
|
||||
return {
|
||||
...character,
|
||||
createdAt: createdAts[characterId],
|
||||
}
|
||||
})
|
||||
.sort((a: any, b: any) => {
|
||||
return b.createdAt > a.createdAt ? 1 : -1
|
||||
})
|
||||
|
||||
return list
|
||||
}
|
||||
|
||||
export const getSubscription = async (
|
||||
|
||||
@@ -8,7 +8,7 @@ const getOriginalScore = async (cid: string) => {
|
||||
try {
|
||||
const { content } = await (await fetch(toGateway(`ipfs://${cid}`))).json()
|
||||
|
||||
if (content) {
|
||||
if (content?.length > 200) {
|
||||
console.time(`fetching score ${cid}`)
|
||||
|
||||
const prompt = `According to rule 1 not too short content, rule 2 good originality and innovation, and rule 3 good fun or logic, give this article a score in the range of 0-100 and explain the reason:
|
||||
@@ -45,6 +45,11 @@ const getOriginalScore = async (cid: string) => {
|
||||
.replace(/^Reason:/, "")
|
||||
.trim(),
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
number: 0,
|
||||
reason: "Content too short",
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
} from "@crossbell/connect-kit"
|
||||
import { useRefCallback } from "@crossbell/util-hooks"
|
||||
import { useContract } from "@crossbell/contract"
|
||||
import { NoteEntity } from "crossbell.js"
|
||||
|
||||
import * as pageModel from "~/models/page.model"
|
||||
|
||||
@@ -233,6 +234,25 @@ export function useCommentPage() {
|
||||
}
|
||||
}
|
||||
|
||||
export function useUpdateComment() {
|
||||
const queryClient = useQueryClient()
|
||||
const contract = useContract()
|
||||
|
||||
return useMutation(
|
||||
async (payload: Parameters<typeof pageModel.updateComment>[0]) => {
|
||||
return pageModel.updateComment(payload, contract)
|
||||
},
|
||||
{
|
||||
onSuccess: (data, variables) => {
|
||||
queryClient.invalidateQueries([
|
||||
"getComments",
|
||||
variables.originalId || variables.pageId,
|
||||
])
|
||||
},
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
export function useGetComments(input: { pageId?: string }) {
|
||||
return useInfiniteQuery({
|
||||
queryKey: ["getComments", input.pageId],
|
||||
|
||||
Reference in New Issue
Block a user