diff --git a/bfrontend/src/Components/Categories/CategoryButton.js b/bfrontend/src/Components/Categories/CategoryButton.js
index fee5bb8..e53fd5f 100644
--- a/bfrontend/src/Components/Categories/CategoryButton.js
+++ b/bfrontend/src/Components/Categories/CategoryButton.js
@@ -1,7 +1,7 @@
-// import CategoryProfile from './CategoryProfile';
+import CategoryProfile from './CategoryProfileLink';
+import gatewayConnection from '../../Gateway/globalGatewayConnection';
import { useHistory } from 'react-router-dom';
-import gatewayConnection from '../../Gateway/globalGatewayConnection';
export default function CategoryButton({ category }) {
const history = useHistory();
@@ -14,12 +14,7 @@ export default function CategoryButton({ category }) {
return (
);
}
\ No newline at end of file
diff --git a/bfrontend/src/Components/Categories/CategoryView.js b/bfrontend/src/Components/Categories/CategoryView.js
index 53ca5a0..01c192b 100644
--- a/bfrontend/src/Components/Categories/CategoryView.js
+++ b/bfrontend/src/Components/Categories/CategoryView.js
@@ -10,29 +10,28 @@ import { useState, useRef, useEffect } from 'react';
function CategoryView({ categories, messages, isHandlingRoute=true, subscribedToCategories, gateway: { isConnected: isGatewayConnected } }) {
const { id } = useParams();
const [ textInput, setTextInput ] = useState('');
+ const [ category, setCategory ] = useState();
+
const textInputRef = useRef(null);
const invisibleBottomMessageRef = useRef(null);
- const dispatch = useDispatch();
- let category;
+ const dispatch = useDispatch();
const scrollToBottom = () => {
if (invisibleBottomMessageRef && invisibleBottomMessageRef.current) {
invisibleBottomMessageRef.current.scrollIntoView({ behaviour: 'smooth' });
}
}
-
+ useEffect(scrollToBottom, [messages]);
+
const handleTextboxKeydown = (e) => {
if (e.key === 'Enter') {
- // Send message written in textbox
-
gatewayConnection.sendMessage(id, textInput);
textInputRef.current.value = '';
+ setTextInput('');
}
}
- useEffect(scrollToBottom, [messages]);
-
useEffect(() => {
if (isHandlingRoute) {
if (!id || id === '') return;
@@ -43,19 +42,31 @@ function CategoryView({ categories, messages, isHandlingRoute=true, subscribedTo
gatewayConnection.subscribeToCategoryChat(id);
}
}, [dispatch, id, isHandlingRoute, subscribedToCategories, isGatewayConnected]);
-
- if (categories) {
- category = categories.find(x => x._id === id);
- }
+
+ useEffect(() => {
+ if (!categories) return;
+
+ setCategory(categories.find(x => x._id === id));
+ }, [ categories, id ]);
if (category) {
+ let messagesView = messages.map(m =>