From b9f1affcbf730bccf71844241b81ea9936f410a6 Mon Sep 17 00:00:00 2001 From: Taliayaya Date: Wed, 18 May 2022 20:57:48 +0200 Subject: [PATCH 1/7] Fixed double click issue on channels --- src/components/ChannelName/index.jsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/ChannelName/index.jsx b/src/components/ChannelName/index.jsx index 2bdf7c0..ea2c062 100644 --- a/src/components/ChannelName/index.jsx +++ b/src/components/ChannelName/index.jsx @@ -46,10 +46,12 @@ const ChannelName = ({ id_channel, name, seen, lastMessageData }) => { * @param {string} name the channel name */ const selectChannel = (id_channel, name) => { - setCurrentChannel({ id: id_channel, name: name }) - // Reset the message list, so that new messages can be loaded - setMessageList([]) - navigate(`${currentServer.name}/${currentServer.id}/${id_channel}`) + if (!isCurrentChannel) { + setCurrentChannel({ id: id_channel, name: name }) + // Reset the message list, so that new messages can be loaded + setMessageList([]) + navigate(`${currentServer.name}/${currentServer.id}/${id_channel}`) + } } /** From c2cd424b3f23b058322a57cc864375cd40feda5e Mon Sep 17 00:00:00 2001 From: Taliayaya Date: Wed, 18 May 2022 21:13:43 +0200 Subject: [PATCH 2/7] !loading more than 50+ messages on a channel (tmp) --- src/components/Chat/index.jsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/components/Chat/index.jsx b/src/components/Chat/index.jsx index 77366ee..9a6fd08 100755 --- a/src/components/Chat/index.jsx +++ b/src/components/Chat/index.jsx @@ -46,6 +46,10 @@ function Chat() { const [shouldScrollToBottom, setShouldScrollToBottom] = useState(true) const user = getAuth().currentUser + // Basically the slice for the array of messages, + // TODO : user should be able to load more + const showLastsMessagesNumber = 50 + /** * This create a realtime connection with the database * On each modification in the messages/channel_id/ node, @@ -94,9 +98,11 @@ function Chat() { let previousUser = -1 // sort message by date. The latest at the top - const messageListSorted = messageList.sort((a, b) => { - return a.timestamp - b.timestamp - }) + const messageListSorted = messageList + .sort((a, b) => { + return a.timestamp - b.timestamp + }) + .slice(showLastsMessagesNumber) const shouldresize = showUsers || showChannel ? 'true' : 'false' return ( From 6b2a53d27d5e1c8c31f21533bce0bc5c3c498468 Mon Sep 17 00:00:00 2001 From: Taliayaya Date: Wed, 18 May 2022 21:15:34 +0200 Subject: [PATCH 3/7] Disabled keyboard navigation on menu textfield --- src/components/LeftMenu/index.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/LeftMenu/index.jsx b/src/components/LeftMenu/index.jsx index a005c72..7302c58 100644 --- a/src/components/LeftMenu/index.jsx +++ b/src/components/LeftMenu/index.jsx @@ -85,7 +85,7 @@ const LeftMenu = ({ serverList, setChannelList }) => { /> {/* Only admins or owners can add new channels */} {hasPower && ( - + e.stopPropagation()}> Date: Wed, 18 May 2022 21:21:47 +0200 Subject: [PATCH 4/7] Positive int to negative one --- src/components/Chat/index.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Chat/index.jsx b/src/components/Chat/index.jsx index 9a6fd08..ef6fd6e 100755 --- a/src/components/Chat/index.jsx +++ b/src/components/Chat/index.jsx @@ -48,7 +48,7 @@ function Chat() { // Basically the slice for the array of messages, // TODO : user should be able to load more - const showLastsMessagesNumber = 50 + const showLastsMessagesNumber = -50 /** * This create a realtime connection with the database From e30ced7b00d6bd761015bb691f92f62366344856 Mon Sep 17 00:00:00 2001 From: Taliayaya Date: Wed, 18 May 2022 21:25:47 +0200 Subject: [PATCH 5/7] To send files without messages --- src/components/MessageInput/index.jsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/MessageInput/index.jsx b/src/components/MessageInput/index.jsx index 887d000..95c025f 100644 --- a/src/components/MessageInput/index.jsx +++ b/src/components/MessageInput/index.jsx @@ -166,7 +166,10 @@ const MessageInput = ({ currentChannel }) => { const { currentServer } = useChannel() const handleSending = async () => { - if (message.trim().length > 0 && userRole !== 'Muted') { + if ( + (message.trim().length > 0 || selectedFiles.length > 0) && + userRole !== 'Muted' + ) { try { writeUserMessage( user, @@ -225,7 +228,7 @@ const MessageInput = ({ currentChannel }) => { maxLength={1000} > - {message.trim().length > 0 && ( + {(message.trim().length > 0 || selectedFiles.length > 0) && ( Date: Wed, 18 May 2022 21:30:44 +0200 Subject: [PATCH 6/7] Clear currentChannel if changing server --- src/components/LeftMenu/index.jsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/LeftMenu/index.jsx b/src/components/LeftMenu/index.jsx index 7302c58..5c330f7 100644 --- a/src/components/LeftMenu/index.jsx +++ b/src/components/LeftMenu/index.jsx @@ -30,7 +30,8 @@ const LeftMenu = ({ serverList, setChannelList }) => { const [newChannelName, setNewChannelName] = useState('') const [error, setError] = useState(null) - const { currentServer, setCurrentServer, setUserList } = useChannel() + const { currentServer, setCurrentServer, setUserList, setCurrentChannel } = + useChannel() const { setMessageList } = useMessageList() const { userRole } = useAuth() @@ -66,10 +67,11 @@ const LeftMenu = ({ serverList, setChannelList }) => { * This was written at midnight. Forgive me */ const server = value.split('§§§§§§§§§§§§§') - setCurrentServer({ id: server[0], name: server[1] }) + setCurrentChannel({}) + setMessageList([]) setChannelList([]) + setCurrentServer({ id: server[0], name: server[1] }) setUserList([]) - setMessageList([]) navigate(`${server[1]}/${server[0]}`) } From 7e3fd950448193f838d478b3ad80770cb6d5e0f8 Mon Sep 17 00:00:00 2001 From: Taliayaya Date: Wed, 18 May 2022 21:50:58 +0200 Subject: [PATCH 7/7] Resolved logged dot issue --- src/components/UserStatus/index.jsx | 31 ++++++++++++++++------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/components/UserStatus/index.jsx b/src/components/UserStatus/index.jsx index c5c2c42..6946c66 100644 --- a/src/components/UserStatus/index.jsx +++ b/src/components/UserStatus/index.jsx @@ -14,10 +14,10 @@ import { useAuth, useChannel } from '../../utils/hooks' import { Add, Block, Remove, VolumeOff } from '@mui/icons-material' import PropTypes from 'prop-types' -const StyledBadge = styled(Badge)(() => ({ +const StyledBadge = styled(Badge)((props) => ({ '& .MuiBadge-badge': { - backgroundColor: (props) => (props.logged ? '#44b700' : '#888888'), - color: (props) => (props.logged ? '#44b700' : '#888888'), + backgroundColor: props.logged ? '#44b700' : '#888888', + color: props.logged ? '#44b700' : '#888888', boxShadow: `0 0 0 5px ${theme.sides_bg_color}`, animation: 'ripple 1s infinite ease', '&::after': { @@ -70,17 +70,20 @@ function UserStatus({ avatar, datediff, name, logged, uid }) { style={{ opacity: opacityValue, cursor: 'context-menu' }} onContextMenu={handleContextMenu} > - - - + {/* To avoid the dot leaving away~~~~ */} +
+ + + +
{/* Show the online users with a better visibility than offline ones