Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

feat: update chatbox #365

Merged
merged 3 commits into from
May 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 1 addition & 20 deletions src/components/common/Chatbox.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useContext, useEffect, useState } from 'react';
import React, { useContext } from 'react';
import PropTypes from 'prop-types';
import GraaspChatbox from '@graasp/chatbox';
import { MUTATION_KEYS } from '@graasp/query-client';
Expand All @@ -8,7 +8,6 @@ import { hooks, useMutation } from '../../config/queryClient';
import { CHATBOX_INPUT_BOX_ID, CHATBOX_ID } from '../../config/selectors';
import { CurrentUserContext } from '../context/CurrentUserContext';
import { PERMISSION_LEVELS } from '../../enums';
import { HEADER_HEIGHT } from '../../config/constants';

const { useItemChat, useMembers, useAvatar, useItemMemberships } = hooks;

Expand All @@ -31,23 +30,6 @@ const Chatbox = ({ item }) => {
MUTATION_KEYS.DELETE_ITEM_CHAT_MESSAGE,
);
const { mutate: clearChat } = useMutation(MUTATION_KEYS.CLEAR_ITEM_CHAT);
const [windowHeight, setWindowHeight] = useState(window.innerHeight);

useEffect(
() => {
const handleResize = () => {
setWindowHeight(window.innerHeight);
};
window.addEventListener('resize', handleResize);

// cleanup eventListener
return () => {
window.removeEventListener('resize', handleResize);
};
},
// run on first render only
[],
);

if (
isChatLoading ||
Expand All @@ -72,7 +54,6 @@ const Chatbox = ({ item }) => {
currentMember={currentMember}
chatId={item.get('id')}
messages={List(chat?.get('messages'))}
height={windowHeight - HEADER_HEIGHT * 2}
showAdminTools={isAdmin}
sendMessageFunction={sendMessage}
deleteMessageFunction={deleteMessage}
Expand Down
Loading