Skip to content

Commit

Permalink
fix/linting
Browse files Browse the repository at this point in the history
  • Loading branch information
umangutkarsh committed Feb 18, 2024
1 parent f866be0 commit 0e9bb43
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 27 deletions.
16 changes: 6 additions & 10 deletions packages/react/src/components/ChatInput/ChatInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ const ChatInput = ({ scrollToBottom }) => {

RCInstance.getChannelMembers(isChannelPrivate)
.then((channelMembers) =>
setMembersHandler(channelMembers.members || []))
setMembersHandler(channelMembers.members || [])
)
.catch(console.error);
}
});
Expand Down Expand Up @@ -280,13 +281,9 @@ const ChatInput = ({ scrollToBottom }) => {
let insertionText;
if (selectedItem === 'all') {
insertionText = `@all `;
}

else if (selectedItem === 'here') {
} else if (selectedItem === 'here') {
insertionText = `@here `;
}

else {
} else {
insertionText = `${messageRef.current.value.substring(
0,
messageRef.current.value.lastIndexOf('@')
Expand All @@ -300,7 +297,6 @@ const ChatInput = ({ scrollToBottom }) => {
messageRef.current.focus();
};


const showCommands = useCallback(
async (e) => {
const cursor = e.target.selectionStart;
Expand Down Expand Up @@ -490,8 +486,8 @@ const ChatInput = ({ scrollToBottom }) => {
isUserAuthenticated && canSendMsg
? 'Message'
: isUserAuthenticated
? 'This room is read only'
: 'Sign in to chat'
? 'This room is read only'
: 'Sign in to chat'
}
className={styles.textInput}
onChange={onTextChange}
Expand Down
18 changes: 8 additions & 10 deletions packages/react/src/components/Markup/elements/Mention.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,22 @@ const Mention = ({ contents }) => {
background-color: ${contents.value === 'all' || contents.value === 'here'
? '#f38c39'
: contents.value === username
? '#ec0d2a'
: '#e4e7ea'
};
? '#ec0d2a'
: '#e4e7ea'};
color: ${contents.value === 'all' || contents.value === 'here'
? '#ffffff' :
contents.value === username
? '#ffffff'
: '#2f343d'
};
? '#ffffff'
: contents.value === username
? '#ffffff'
: '#2f343d'};
font-weight: bold;
cursor: pointer;
padding: 1.5px;
border-radius: 3px;
&:hover {
text-decoration: ${contents.value === 'all' || contents.value === 'here'
? 'none'
: 'underline'};
? 'none'
: 'underline'};
}
`;

Expand Down
45 changes: 39 additions & 6 deletions packages/react/src/components/Mentions/MembersList.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,30 +57,51 @@ function MembersList({ mentionIndex, filteredMembers = [], onMemberClick }) {
mentionIndex < filteredMembers.length
? filteredMembers[mentionIndex]
: mentionIndex === filteredMembers.length
? 'all'
: 'here';
? 'all'
: 'here';
handleMemberClick(selectedItem);
}
};

const handleKeyDown = (event) => {
if (event.key === 'Enter') {
event.preventDefault();
}
};

document.addEventListener('keydown', handleKeyPress);
document.addEventListener('keydown', handleKeyDown);

return () => {
document.removeEventListener('keydown', handleKeyPress);
document.removeEventListener('keydown', handleKeyDown);
};
}, [mentionIndex, filteredMembers, handleMemberClick]);

return (
<Box css={listStyle}>
<Box
css={listStyle}
onKeyDown={(e) => {
if (e.key === 'Enter') {
e.preventDefault();
}
}}
>
<ul style={{ listStyle: 'none' }}>
{filteredMembers.map((member, index) => (
<li
key={member._id}
css={listItemStyle}
onClick={() => handleMemberClick(member)}
onKeyDown={(e) => {
if (e.key === 'Enter') {
handleMemberClick(member);
}
}}
tabIndex={0}
style={{
backgroundColor: index === mentionIndex && '#dddddd',
}}
onClick={() => handleMemberClick(member)}
>
<span style={{ justifyContent: 'space-evenly' }}>
<span css={listTextStyle}>{member.name}</span>
Expand All @@ -92,22 +113,34 @@ function MembersList({ mentionIndex, filteredMembers = [], onMemberClick }) {
<li
key="all"
css={listItemStyle}
onClick={() => handleMemberClick('all')}
onKeyDown={(e) => {
if (e.key === 'Enter') {
handleMemberClick('all');
}
}}
tabIndex={0}
style={{
backgroundColor:
mentionIndex === filteredMembers.length && '#dddddd',
}}
onClick={() => handleMemberClick('all')}
>
<span css={listTextStyle}>all</span>
</li>
<li
key="here"
css={listItemStyle}
onClick={() => handleMemberClick('here')}
onKeyDown={(e) => {
if (e.key === 'Enter') {
handleMemberClick('here');
}
}}
tabIndex={0}
style={{
backgroundColor:
mentionIndex === filteredMembers.length + 1 && '#dddddd',
}}
onClick={() => handleMemberClick('here')}
>
<span css={listTextStyle}>here</span>
</li>
Expand Down
1 change: 0 additions & 1 deletion packages/react/src/lib/searchToMentionUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export const searchToMentionUser = (
member.username.toLowerCase().includes(query)
);


if (isValidUsername) {
setshowMembersList(true);
setmentionIndex(0);
Expand Down

0 comments on commit 0e9bb43

Please sign in to comment.