refactor: avatar_file_hash instead of avatar

This commit is contained in:
CrescentLeaf
2025-10-24 20:29:51 +08:00
parent bef6e88bf7
commit 72016c5da1
13 changed files with 40 additions and 28 deletions

View File

@@ -1,4 +1,5 @@
import Chat from "../../api/client_data/Chat.ts"
import getUrlForFileByHash from "../../getUrlForFileByHash.ts"
import Avatar from "../Avatar.tsx"
import React from 'react'
@@ -8,7 +9,7 @@ interface Args extends React.HTMLAttributes<HTMLElement> {
}
export default function ContactsListItem({ contact, ...prop }: Args) {
const { id, title, avatar } = contact
const { id, title, avatar_file_hash } = contact
const ref = React.useRef<HTMLElement>(null)
return (
@@ -20,7 +21,7 @@ export default function ContactsListItem({ contact, ...prop }: Args) {
<span style={{
width: "100%",
}}>{title}</span>
<Avatar src={avatar as string} text={title} slot="icon" />
<Avatar src={getUrlForFileByHash(avatar_file_hash as string)} text={title} slot="icon" />
</mdui-list-item>
)
}

View File

@@ -2,6 +2,7 @@ import { $ } from "mdui/jq"
import RecentChat from "../../api/client_data/RecentChat.ts"
import Avatar from "../Avatar.tsx"
import React from 'react'
import getUrlForFileByHash from "../../getUrlForFileByHash.ts"
interface Args extends React.HTMLAttributes<HTMLElement> {
recentChat: RecentChat
@@ -10,7 +11,7 @@ interface Args extends React.HTMLAttributes<HTMLElement> {
}
export default function RecentsListItem({ recentChat, openChatFragment, active }: Args) {
const { id, title, avatar, content } = recentChat
const { id, title, avatar_file_hash, content } = recentChat
const itemRef = React.useRef<HTMLElement>(null)
React.useEffect(() => {
@@ -22,7 +23,7 @@ export default function RecentsListItem({ recentChat, openChatFragment, active }
marginBottom: '3px',
}} onClick={() => openChatFragment(id)} active={active} ref={itemRef}>
{title}
<Avatar src={avatar} text={title} slot="icon" />
<Avatar src={getUrlForFileByHash(avatar_file_hash as string)} text={title} slot="icon" />
<span slot="description"
style={{
width: "100%",