Skip to content

Commit

Permalink
feat: update chatbox (#365)
Browse files Browse the repository at this point in the history
* feat: update chatbox

* chore: update yarn.lock
  • Loading branch information
spaenleh authored May 24, 2022
1 parent 12f7e38 commit a46d9e6
Show file tree
Hide file tree
Showing 2 changed files with 1,665 additions and 687 deletions.
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

0 comments on commit a46d9e6

Please sign in to comment.