feat: filter out comments that are too short in length in the activities
This commit is contained in:
@@ -19,7 +19,7 @@ import { useDate } from "~/hooks/useDate"
|
||||
import { useTranslation } from "~/lib/i18n/client"
|
||||
import { getStorage, setStorage } from "~/lib/storage"
|
||||
import { ExpandedNote } from "~/lib/types"
|
||||
import { cn } from "~/lib/utils"
|
||||
import { cn, getStringLength } from "~/lib/utils"
|
||||
import type { FeedType, SearchType } from "~/models/home.model"
|
||||
import { useGetFeed } from "~/queries/home"
|
||||
|
||||
@@ -146,6 +146,12 @@ const Post = ({
|
||||
if (post.toNote?.metadata?.content?.tags?.includes("comment")) {
|
||||
return null
|
||||
}
|
||||
if (
|
||||
!post.metadata?.content?.summary ||
|
||||
getStringLength(post.metadata.content.summary) < 6
|
||||
) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -48,3 +48,16 @@ export const calculateElementTop = (el: HTMLElement) => {
|
||||
}
|
||||
return top
|
||||
}
|
||||
|
||||
export function getStringLength(str: string) {
|
||||
let len = 0
|
||||
for (let i = 0; i < str.length; i++) {
|
||||
const code = str.charCodeAt(i)
|
||||
if (code >= 0 && code <= 128) {
|
||||
len += 1
|
||||
} else {
|
||||
len += 2
|
||||
}
|
||||
}
|
||||
return len
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user