* Feature 🚀 : Ability to delete messages in chat channels - Sending message ID to frontend - Deleting Message - Use pusher to delete message realtime * Minor Bug 🐞: Show message action only for current user - User can delete or edit their own messages * Test cases added * Bug 🐞: Update message id for receiver Message id was not sent to receiver by pusher * Refactoring🛠: Message controller refactoring * Test Cases📝 : Specs for Delete message added * Feature 🚀 : Ability to edit messages * Test Cases📝 : Specs for Edit message added * Feature 🚀 : Ability to mention member in Group [Frontend] * Test Cases📝 : Test Cases added * Feature 🚀 : Ability to mention member in Group [Backend] * Bug Fix 🐞: Making messages realtime for open channels * Feature 🚀 and Bug Fix 🐞: Ability to get notification if mentioned in open messages and increasing message number count * Feature 🚀 : Ability to remove message count on channel open * Bug Fix 🐞: Making Notification more reliable by checking if the new message is notified to user or not * Feature 🚀 : Ability to metion @all and notify them * Bug Fix 🐞: Minor fixes * Fews tweaks in code * Bug Fix 🐞: Feature was not present for Invite only Section * Bug Fix 🐞: In open channels one can't mention all * Bug Fix 🐞: Markdown conversion for all only in case of invite only * Specs added * Delete schema.rb * Schema file updated * Code refactoring * Further Code refactoring backend * Further Code refactoring backend * Bug Fix 🐞: Mention List error problem in switching tabs * Test Snapshots added * Feature 🚀 : Ability to mention member in Group [Frontend] * Test Cases📝 : Test Cases added * Feature 🚀 : Ability to mention member in Group [Backend] * Bug Fix 🐞: Making messages realtime for open channels * Feature 🚀 and Bug Fix 🐞: Ability to get notification if mentioned in open messages and increasing message number count * Feature 🚀 : Ability to remove message count on channel open * Bug Fix 🐞: Making Notification more reliable by checking if the new message is notified to user or not * Feature 🚀 : Ability to metion @all and notify them * Bug Fix 🐞: Minor fixes * Fews tweaks in code * Bug Fix 🐞: Feature was not present for Invite only Section * Bug Fix 🐞: In open channels one can't mention all * Bug Fix 🐞: Markdown conversion for all only in case of invite only * Specs added * Code refactoring * Further Code refactoring backend * Further Code refactoring backend * Bug Fix 🐞: Mention List error problem in switching tabs * Test Snapshots added * Feature 🚀: Ability to navigate through user list with keyboard only * Bug Fix 🐞: Changing color of group avatars in dark themes * Bug Fix 🐞: Setup pusher channel for open channels also
118 lines
3.2 KiB
JavaScript
118 lines
3.2 KiB
JavaScript
import { h, Component } from 'preact';
|
|
import PropTypes from 'prop-types';
|
|
|
|
export default class Chat extends Component {
|
|
static propTypes = {
|
|
handleKeyDown: PropTypes.func.isRequired,
|
|
handleKeyDownEdit: PropTypes.func.isRequired,
|
|
handleSubmitOnClick: PropTypes.func.isRequired,
|
|
handleSubmitOnClickEdit: PropTypes.func.isRequired,
|
|
handleMention: PropTypes.func.isRequired,
|
|
handleKeyUp: PropTypes.func.isRequired,
|
|
startEditing: PropTypes.bool.isRequired,
|
|
markdownEdited: PropTypes.bool.isRequired,
|
|
editMessageHtml: PropTypes.string.isRequired,
|
|
editMessageMarkdown: PropTypes.string.isRequired,
|
|
handleEditMessageClose: PropTypes.func.isRequired,
|
|
};
|
|
|
|
componentDidUpdate() {
|
|
const { editMessageMarkdown, markdownEdited, startEditing } = this.props;
|
|
const textarea = document.getElementById('messageform');
|
|
if (!markdownEdited && startEditing) {
|
|
textarea.value = editMessageMarkdown;
|
|
}
|
|
}
|
|
|
|
messageCompose = () => {
|
|
const {
|
|
handleSubmitOnClickEdit,
|
|
handleKeyDownEdit,
|
|
handleEditMessageClose,
|
|
handleMention,
|
|
handleKeyUp,
|
|
editMessageHtml,
|
|
} = this.props;
|
|
|
|
return (
|
|
<div className="messagecomposer">
|
|
<div className="messageToBeEdited">
|
|
<div className="message">
|
|
<span className="editHead">Edit Message</span>
|
|
<div
|
|
// eslint-disable-next-line react/no-danger
|
|
dangerouslySetInnerHTML={{
|
|
__html: editMessageHtml,
|
|
}}
|
|
/>
|
|
</div>
|
|
<div
|
|
className="closeEdit"
|
|
role="button"
|
|
onClick={handleEditMessageClose}
|
|
tabIndex="0"
|
|
onKeyUp={e => {
|
|
if (e.keyCode === 13) handleEditMessageClose();
|
|
}}
|
|
>
|
|
x
|
|
</div>
|
|
</div>
|
|
<textarea
|
|
className="messagecomposer__input"
|
|
id="messageform"
|
|
placeholder="Message goes here"
|
|
onKeyDown={handleKeyDownEdit}
|
|
onKeyPress={handleMention}
|
|
onKeyUp={handleKeyUp}
|
|
maxLength="1000"
|
|
/>
|
|
<button
|
|
type="button"
|
|
className="messagecomposer__submit"
|
|
onClick={handleSubmitOnClickEdit}
|
|
>
|
|
Save
|
|
</button>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
textAreaSection = () => {
|
|
const {
|
|
handleSubmitOnClick,
|
|
handleKeyDown,
|
|
handleMention,
|
|
handleKeyUp,
|
|
} = this.props;
|
|
return (
|
|
<div className="messagecomposer">
|
|
<textarea
|
|
className="messagecomposer__input"
|
|
id="messageform"
|
|
placeholder="Message goes here"
|
|
onKeyDown={handleKeyDown}
|
|
onKeyPress={handleMention}
|
|
onKeyUp={handleKeyUp}
|
|
maxLength="1000"
|
|
/>
|
|
<button
|
|
type="button"
|
|
className="messagecomposer__submit"
|
|
onClick={handleSubmitOnClick}
|
|
>
|
|
SEND
|
|
</button>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
render() {
|
|
const { startEditing } = this.props;
|
|
return (
|
|
<div className="compose__outer__container">
|
|
{!startEditing ? this.textAreaSection() : this.messageCompose()}
|
|
</div>
|
|
);
|
|
}
|
|
}
|