Skip to content

Commit

Permalink
Fix/#334 source image fix (#335)
Browse files Browse the repository at this point in the history
* added-babel-config

* mods

* changed-host-to-dynamic

* construct-source-using-host

* used URL object to create url using host as base

Signed-off-by: Abhinav Kumar <[email protected]>

* added changesets

Signed-off-by: Abhinav Kumar <[email protected]>

---------

Signed-off-by: Abhinav Kumar <[email protected]>
Co-authored-by: Abhinav Kumar <[email protected]>
  • Loading branch information
umangutkarsh and abhinavkrin authored Dec 13, 2023
1 parent 100c5f7 commit c8c9dee
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 19 deletions.
5 changes: 5 additions & 0 deletions .changeset/thick-moose-reply.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@embeddedchat/react": patch
---

Fix: Room members avatar invalid avatar url creation
6 changes: 4 additions & 2 deletions packages/react/src/components/RoomMembers/RoomMember.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import RoomMemberItem from './RoomMemberItem';
import classes from './RoomMember.module.css';
import { useMemberStore } from '../../store';
import RCContext from '../../context/RCInstance';
import RCContext, { useRCContext } from '../../context/RCInstance';
import useInviteStore from '../../store/inviteStore';
import InviteMembers from './inviteMembers/InviteMembers';
import { Button } from '../Button';
Expand All @@ -13,6 +13,8 @@ import { ActionButton } from '../ActionButton';

const RoomMembers = ({ members }) => {
const { RCInstance } = useContext(RCContext);
const { ECOptions } = useRCContext();
const { host } = ECOptions;

const toggleShowMembers = useMemberStore((state) => state.toggleShowMembers);
const toggleInviteView = useInviteStore((state) => state.toggleInviteView);
Expand All @@ -39,7 +41,7 @@ const RoomMembers = ({ members }) => {
</Box>
<Box className={classes.container}>
{members.map((member) => (
<RoomMemberItem user={member} key={member._id} />
<RoomMemberItem user={member} host={host} key={member._id} />
))}
</Box>
<Button
Expand Down
37 changes: 20 additions & 17 deletions packages/react/src/components/RoomMembers/RoomMemberItem.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
import React from 'react';
import PropTypes from 'prop-types';

const RoomMemberItem = ({ user }) => (
<div
style={{
width: '100%',
paddingBottom: '8px',
paddingTop: '8px',
display: 'flex',
}}
>
<img
src={`http://localhost:3000/avatar/${user.username}`}
alt="avatar"
style={{ height: '1.5rem', marginLeft: '0.5rem' }}
/>
<span style={{ marginLeft: '1.2rem' }}>{user.username}</span>
</div>
);
const RoomMemberItem = ({ user, host }) => {
const avatarUrl = new URL(`avatar/${user.username}`, host).toString();
return (
<div
style={{
width: '100%',
paddingBottom: '8px',
paddingTop: '8px',
display: 'flex',
}}
>
<img
src={avatarUrl}
alt="avatar"
style={{ height: '1.5rem', marginLeft: '0.5rem' }}
/>
<span style={{ marginLeft: '1.2rem' }}>{user.username}</span>
</div>
);
};

export default RoomMemberItem;

Expand Down

0 comments on commit c8c9dee

Please sign in to comment.