消除了两个空指针错误

This commit is contained in:
CrescentLeaf
2025-11-09 16:52:29 +08:00
parent 31133f5704
commit 5b425260c9
2 changed files with 3 additions and 1 deletions

View File

@@ -148,7 +148,7 @@ export default function ChatFragment({ target, showReturnButton, onReturnButtonC
const oldest = messagesList[0]
setMessagesList(returnMsgs.concat(messagesList))
setTimeout(() => chatPanelRef.current!.scrollTo({ top: $(`#chat_${target}_message_${oldest.id}`).get(0).offsetTop }), 200)
oldest && setTimeout(() => chatPanelRef.current!.scrollTo({ top: $(`#chat_${target}_message_${oldest.id}`).get(0).offsetTop }), 200)
}
React.useEffect(() => {

View File

@@ -22,6 +22,8 @@ customElements.define('chat-text', class extends HTMLElement {
this.update()
}
update() {
if (this.span == null) return
this.span.textContent = this.textContent
this.span.style.textDecoration = $(this).attr('underline') ? 'underline' : ''
this.span.style.fontStyle = $(this).attr('em') ? 'italic' : ''