aboutsummaryrefslogtreecommitdiff
path: root/vnext/src/ui/Chat.js
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2022-10-31 22:48:30 +0300
committerGravatar Vitaly Takmazov2023-01-13 10:37:58 +0300
commit8887e1b51565b992f34c955c459125eb85b28483 (patch)
tree7fc8130f523014864e2d60aa9628e7a7ee7e7dd5 /vnext/src/ui/Chat.js
parentfc96a9a206a825171da87a7f23cc2ea16b1d645d (diff)
`useVisitor` hook
Diffstat (limited to 'vnext/src/ui/Chat.js')
-rw-r--r--vnext/src/ui/Chat.js7
1 files changed, 4 insertions, 3 deletions
diff --git a/vnext/src/ui/Chat.js b/vnext/src/ui/Chat.js
index 5ecb9c0f..cdf3de1b 100644
--- a/vnext/src/ui/Chat.js
+++ b/vnext/src/ui/Chat.js
@@ -9,10 +9,10 @@ import UserInfo from './UserInfo';
import { getChat, pm } from '../api';
import './Chat.css';
+import { useVisitor } from './VisitorContext';
/**
* @typedef {Object} ChatProps
- * @property {import('../api').SecureUser} visitor
* @property {EventSource} connection
*/
@@ -21,11 +21,12 @@ import './Chat.css';
* @param {ChatProps} props
*/
export default function Chat(props) {
+ const [visitor] = useVisitor();
const [chats, setChats] = useState([]);
const params = useParams();
let loadChat = useCallback((uname) => {
- const { hash } = props.visitor;
+ const { hash } = visitor;
setChats([]);
if (hash && uname) {
getChat(uname)
@@ -33,7 +34,7 @@ export default function Chat(props) {
setChats(response.data);
});
}
- }, [props.visitor]);
+ }, []);
let onMessage = useCallback((json) => {
const msg = JSON.parse(json.data);