forked from Mirrors/gomuks
web/roomview: fix placeholder avatars in room view header
This commit is contained in:
parent
a7a2fc53f2
commit
f0e3ec650d
1 changed files with 4 additions and 2 deletions
|
@ -14,7 +14,7 @@
|
|||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
import { use, useRef } from "react"
|
||||
import { getMediaURL } from "@/api/media.ts"
|
||||
import { getAvatarURL } from "@/api/media.ts"
|
||||
import { RoomStateStore } from "@/api/statestore"
|
||||
import { EventID } from "@/api/types"
|
||||
import { useNonNullEventAsState } from "@/util/eventdispatcher.ts"
|
||||
|
@ -31,12 +31,14 @@ interface RoomViewProps {
|
|||
|
||||
const RoomHeader = ({ room, clearActiveRoom }: RoomViewProps) => {
|
||||
const roomMeta = useNonNullEventAsState(room.meta)
|
||||
const avatarSourceID = roomMeta.lazy_load_summary?.heroes?.length === 1
|
||||
? roomMeta.lazy_load_summary.heroes[0] : room.roomID
|
||||
return <div className="room-header">
|
||||
<button className="back" onClick={clearActiveRoom}><BackIcon/></button>
|
||||
<img
|
||||
className="avatar"
|
||||
loading="lazy"
|
||||
src={getMediaURL(roomMeta.avatar)}
|
||||
src={getAvatarURL(avatarSourceID, { avatar_url: roomMeta.avatar, displayname: roomMeta.name })}
|
||||
onClick={use(LightboxContext)!}
|
||||
alt=""
|
||||
/>
|
||||
|
|
Loading…
Add table
Reference in a new issue