Skip to content

Commit

Permalink
fix/lint-err
Browse files Browse the repository at this point in the history
  • Loading branch information
umangutkarsh committed Feb 17, 2024
1 parent 2e9f9a7 commit 09c13f5
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 23 deletions.
5 changes: 3 additions & 2 deletions packages/react/src/components/ChatInput/ChatInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
useMessageStore,
loginModalStore,
useChannelStore,
useMemberStore
useMemberStore,
} from '../../store';
import ChatInputFormattingToolbar from './ChatInputFormattingToolbar';
import useAttachmentWindowStore from '../../store/attachmentwindow';
Expand Down Expand Up @@ -59,7 +59,8 @@ const ChatInput = ({ scrollToBottom }) => {
.catch(console.error);

RCInstance.getChannelMembers(isChannelPrivate)
.then((channelMembers) => setMembersHandler(channelMembers.members || []))
.then((channelMembers) =>
setMembersHandler(channelMembers.members || []))
.catch(console.error);
}
});
Expand Down
26 changes: 15 additions & 11 deletions packages/react/src/components/Markup/elements/Mention.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { css } from '@emotion/react'
import { css } from '@emotion/react';
import PropTypes from 'prop-types';
import { useMemberStore, useUserStore } from '../../../store';

Expand All @@ -8,19 +8,27 @@ const Mention = ({ contents }) => {
const username = useUserStore((state) => state.username);

const mentionStyles = css`
background-color: ${contents.value === 'all' || contents.value === 'here' ? '#f38c39' :
(contents.value === username ? '#ec0d2a' : '#e4e7ea')
background-color: ${contents.value === 'all' || contents.value === 'here'
? '#f38c39'
: contents.value === username
? '#ec0d2a'
: '#e4e7ea'
};
color: ${contents.value === 'all' || contents.value === 'here' ? '#ffffff' :
(contents.value === username ? '#ffffff' : '#2f343d')
color: ${contents.value === 'all' || contents.value === 'here'
? '#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'};
text-decoration: ${contents.value === 'all' || contents.value === 'here'
? 'none'
: 'underline'};
}
`;

Expand All @@ -37,11 +45,7 @@ const Mention = ({ contents }) => {
return (
<>
{hasMember(contents.value) === true ? (
<span
css={mentionStyles}
>
{contents.value}
</span>
<span css={mentionStyles}>{contents.value}</span>
) : (
`@${contents.value}`
)}
Expand Down
19 changes: 10 additions & 9 deletions packages/react/src/components/Mentions/MembersList.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useEffect } from 'react';
import { css } from '@emotion/react';
import { Box } from '../Box';
import PropTypes from 'prop-types';
import { Box } from '../Box';

function MembersList({ mentionIndex, filteredMembers = [], onMemberClick }) {
const listStyle = css`
Expand Down Expand Up @@ -30,10 +30,10 @@ function MembersList({ mentionIndex, filteredMembers = [], onMemberClick }) {

const listItemStyle = css`
cursor: pointer;
display: flex;
justify-content: space-between;
align-items: center;
padding-left: 0;
display: flex;
justify-content: space-between;
align-items: center;
padding-left: 0;
padding-right: 2px;
&:hover {
Expand All @@ -46,7 +46,6 @@ function MembersList({ mentionIndex, filteredMembers = [], onMemberClick }) {
font-weight: 600;
`;


const handleMemberClick = (selectedItem) => {
onMemberClick(selectedItem);
};
Expand All @@ -55,8 +54,11 @@ function MembersList({ mentionIndex, filteredMembers = [], onMemberClick }) {
const handleKeyPress = (event) => {
if (event.key === 'Enter') {
const selectedItem =
mentionIndex < filteredMembers.length ? filteredMembers[mentionIndex] :
mentionIndex === filteredMembers.length ? 'all' : 'here';
mentionIndex < filteredMembers.length
? filteredMembers[mentionIndex]
: mentionIndex === filteredMembers.length
? 'all'
: 'here';
handleMemberClick(selectedItem);
}
};
Expand All @@ -68,7 +70,6 @@ function MembersList({ mentionIndex, filteredMembers = [], onMemberClick }) {
};
}, [mentionIndex, filteredMembers, handleMemberClick]);


return (
<Box css={listStyle}>
<ul style={{ listStyle: 'none' }}>
Expand Down
4 changes: 3 additions & 1 deletion packages/react/src/lib/searchToMentionUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ export const searchToMentionUser = (
setmentionIndex(-1);
setshowMembersList(false);
} else {
const query = message.substring(message.lastIndexOf('@') + 1).toLowerCase();
const query = message
.substring(message.lastIndexOf('@') + 1)
.toLowerCase();
const filteredMentionMembers = roomMembers.filter(
(member) =>
member.name.toLowerCase().includes(query) ||
Expand Down

0 comments on commit 09c13f5

Please sign in to comment.