Compare commits

...

2 Commits

Author SHA1 Message Date
CrescentLeaf
326d62a8bd fix: LazyChatFragment 的依赖忘记修改导致无法使用 2026-01-16 23:45:19 +08:00
CrescentLeaf
25e5650441 chore: 移除了一条注释 2026-01-16 23:44:33 +08:00
2 changed files with 11 additions and 7 deletions

View File

@@ -73,7 +73,7 @@ export default class MduiPatchedTextAreaElement extends HTMLElement {
shadow.appendChild(this.inputContainerDiv) shadow.appendChild(this.inputContainerDiv)
} }
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) { attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {
console.log(this.inputDiv, name, oldValue, newValue) // console.log(this.inputDiv, name, oldValue, newValue)
switch (name) { switch (name) {
case 'value': { case 'value': {
this.value = newValue || '' this.value = newValue || ''

View File

@@ -1,14 +1,18 @@
import { Chat } from "lingchair-client-protocol" import { Chat } from "lingchair-client-protocol"
import { Await } from "react-router"
import getClient from "../../getClient" import getClient from "../../getClient"
import ChatFragment from "./ChatFragment" import ChatFragment from "./ChatFragment"
import * as React from 'react' import * as React from 'react'
import EffectOnly from "../EffectOnly" import useAsyncEffect from "../../utils/useAsyncEffect"
export default function LazyChatFragment({ chatId, openedInDialog }: { chatId: string, openedInDialog: boolean }) { export default function LazyChatFragment({ chatId, openedInDialog }: { chatId: string, openedInDialog: boolean }) {
return <React.Suspense fallback={<EffectOnly effect={() => {}} deps={[]} />}> const [child, setChild] = React.useState<React.ReactNode>()
<Await const chatInfoPromise = React.useMemo(() => Chat.getByIdOrThrow(getClient(), chatId), [chatId])
resolve={React.useMemo(() => Chat.getByIdOrThrow(getClient(), chatId), [chatId])}
children={(chatInfo: Chat) => <ChatFragment chatInfo={chatInfo} openedInDialog={openedInDialog} />} /> useAsyncEffect(async () => {
setChild(<ChatFragment chatInfo={await chatInfoPromise} openedInDialog={openedInDialog} />)
}, [chatId])
return <React.Suspense fallback={null}>
{child}
</React.Suspense> </React.Suspense>
} }