mirror of
https://github.com/linsa-io/linsa.git
synced 2026-01-12 12:20:23 +01:00
fix: remove unnecessary rerender link list
This commit is contained in:
@@ -153,10 +153,8 @@ export const LinkForm: React.FC<LinkFormProps> = ({
|
||||
})
|
||||
|
||||
const topicName = form.watch("topic")
|
||||
const findTopic = React.useMemo(
|
||||
() => me && Topic.findUnique({ topicName }, JAZZ_GLOBAL_GROUP_ID, me),
|
||||
[topicName, me],
|
||||
)
|
||||
const findTopic =
|
||||
me && Topic.findUnique({ topicName }, JAZZ_GLOBAL_GROUP_ID, me)
|
||||
|
||||
const selectedTopic = useCoState(Topic, findTopic, {})
|
||||
|
||||
|
||||
@@ -67,32 +67,20 @@ const LinkList: React.FC<LinkListProps> = () => {
|
||||
|
||||
const { deleteLink } = useLinkActions()
|
||||
const confirm = useConfirm()
|
||||
const { me } = useAccount({ root: { personalLinks: [] } })
|
||||
const { me } = useAccount({ root: { personalLinks: [{}] } })
|
||||
|
||||
const personalLinks = React.useMemo(
|
||||
() => me?.root?.personalLinks || [],
|
||||
[me?.root?.personalLinks],
|
||||
)
|
||||
|
||||
const filteredLinks = React.useMemo(
|
||||
() =>
|
||||
personalLinks.filter((link) => {
|
||||
if (state === "all") return true
|
||||
if (!link?.learningState) return false
|
||||
return link.learningState === state
|
||||
}),
|
||||
[personalLinks, state],
|
||||
)
|
||||
|
||||
const sortedLinks = React.useMemo(
|
||||
() =>
|
||||
sort === "title"
|
||||
? [...filteredLinks].sort((a, b) =>
|
||||
(a?.title || "").localeCompare(b?.title || ""),
|
||||
)
|
||||
: filteredLinks,
|
||||
[filteredLinks, sort],
|
||||
)
|
||||
const personalLinks = me?.root.personalLinks || []
|
||||
const filteredLinks = personalLinks.filter((link) => {
|
||||
if (state === "all") return true
|
||||
if (!link?.learningState) return false
|
||||
return link.learningState === state
|
||||
})
|
||||
const sortedLinks =
|
||||
sort === "title"
|
||||
? [...filteredLinks].sort((a, b) =>
|
||||
(a?.title || "").localeCompare(b?.title || ""),
|
||||
)
|
||||
: filteredLinks
|
||||
|
||||
React.useEffect(() => {
|
||||
if (editId) {
|
||||
@@ -208,7 +196,7 @@ const LinkList: React.FC<LinkListProps> = () => {
|
||||
const handleDragEnd = (event: DragEndEvent) => {
|
||||
const { active, over } = event
|
||||
|
||||
if (!active || !over || !me?.root?.personalLinks) {
|
||||
if (!active || !over || !me?.root.personalLinks) {
|
||||
console.error("Drag operation fail", { active, over })
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user