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