Compare commits
5 commits
c288cfef94
...
f3803e95f6
| Author | SHA1 | Date | |
|---|---|---|---|
| f3803e95f6 | |||
| b0ec30d18b | |||
| bcb98efeca | |||
| 497364c126 | |||
| 1b0671b34c |
2 changed files with 108 additions and 105 deletions
|
|
@ -3,7 +3,9 @@ import React from 'react';
|
|||
class Messages extends React.Component {
|
||||
state = { messages: this.props.messages };
|
||||
|
||||
close = (index) => {
|
||||
close = ::this.close;
|
||||
|
||||
close(index) {
|
||||
const newMessages = this.state.messages.filter((message, currentIndex) => {
|
||||
return currentIndex != index;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -7,9 +7,10 @@ import { SAVED_TYPE } from '../constants.js';
|
|||
import { formatDatetime } from '../../../utils.js';
|
||||
|
||||
class PostModal extends React.Component {
|
||||
readTimer = null;
|
||||
modalListener = ::this.modalListener;
|
||||
readTimer = null;
|
||||
|
||||
componentDidMount() {
|
||||
componentDidMount() {
|
||||
const post = { ...this.props.post };
|
||||
const markPostRead = this.props.markPostRead;
|
||||
const token = Cookies.get('csrftoken');
|
||||
|
|
@ -19,9 +20,9 @@ class PostModal extends React.Component {
|
|||
}
|
||||
|
||||
window.addEventListener('click', this.modalListener);
|
||||
}
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
componentWillUnmount() {
|
||||
if (this.readTimer) {
|
||||
clearTimeout(this.readTimer);
|
||||
}
|
||||
|
|
@ -29,17 +30,17 @@ class PostModal extends React.Component {
|
|||
this.readTimer = null;
|
||||
|
||||
window.removeEventListener('click', this.modalListener);
|
||||
}
|
||||
}
|
||||
|
||||
modalListener = (e) => {
|
||||
modalListener(e) {
|
||||
const targetClassName = e.target.className;
|
||||
|
||||
if (this.props.post && targetClassName == 'modal post-modal') {
|
||||
this.props.unSelectPost();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
render() {
|
||||
const post = this.props.post;
|
||||
const token = Cookies.get('csrftoken');
|
||||
const publicationDate = formatDatetime(post.publicationDate);
|
||||
|
|
@ -66,7 +67,7 @@ class PostModal extends React.Component {
|
|||
<div className="post__actions">
|
||||
<button
|
||||
className={`button read-button ${readButtonDisabled &&
|
||||
'button--disabled'}`}
|
||||
'button--disabled'}`}
|
||||
onClick={() =>
|
||||
!readButtonDisabled && this.props.markPostRead(post, token)
|
||||
}
|
||||
|
|
@ -131,7 +132,7 @@ class PostModal extends React.Component {
|
|||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue