1
- import BaseComponent from 'libs/components/BaseComponent' ;
2
1
import React , { PropTypes } from 'react' ;
3
- import { FormattedMessage , injectIntl , intlShape } from 'react-intl' ;
4
- import CommentForm from './CommentForm/CommentForm' ;
5
- import CommentList , { CommentPropTypes } from './CommentList/CommentList' ;
6
- import css from './CommentBox.scss' ;
7
2
import Immutable from 'immutable' ;
8
3
import ActionCable from 'actioncable' ;
9
- import { SelectLanguage } from 'libs/i18n/selectLanguage' ;
4
+ import _ from 'lodash' ;
5
+ import BaseComponent from 'libs/components/BaseComponent' ;
6
+ import { injectIntl , intlShape } from 'react-intl' ;
7
+ import SelectLanguage from 'libs/i18n/selectLanguage' ;
10
8
import { defaultMessages , defaultLocale } from 'libs/i18n/default' ;
11
9
10
+ import CommentForm from './CommentForm/CommentForm' ;
11
+ import CommentList , { CommentPropTypes } from './CommentList/CommentList' ;
12
+ import css from './CommentBox.scss' ;
13
+
12
14
class CommentBox extends BaseComponent {
13
15
static propTypes = {
14
16
pollInterval : PropTypes . number . isRequired ,
@@ -34,18 +36,21 @@ class CommentBox extends BaseComponent {
34
36
35
37
subscribeChannel ( ) {
36
38
const { messageReceived } = this . props . actions ;
37
- const protocol = window . location . protocol === "https:" ? "wss://" : "ws://"
38
- this . cable = ActionCable . createConsumer ( protocol + window . location . hostname + ":" + window . location . port + "/cable" ) ;
39
- this . cable . subscriptions . create ( { channel : "CommentsChannel" } , {
39
+ const protocol = window . location . protocol === 'https:' ? 'wss://' : 'ws://' ;
40
+ const cableUrl = `${ protocol } ${ window . location . hostname } :${ window . location . port } /cable` ;
41
+ this . cable = ActionCable . createConsumer ( cableUrl ) ;
42
+
43
+ /* eslint no-console: ["error", { allow: ["log"] }] */
44
+ this . cable . subscriptions . create ( { channel : 'CommentsChannel' } , {
40
45
connected : ( ) => {
41
- console . log ( " connected" )
46
+ console . log ( ' connected' ) ;
42
47
} ,
43
48
disconnected : ( ) => {
44
- console . log ( " disconnected" )
49
+ console . log ( ' disconnected' ) ;
45
50
} ,
46
51
received : ( comment ) => {
47
52
messageReceived ( Immutable . fromJS ( comment ) ) ;
48
- }
53
+ } ,
49
54
} ) ;
50
55
}
51
56
@@ -56,7 +61,7 @@ class CommentBox extends BaseComponent {
56
61
}
57
62
58
63
componentWillUnmount ( ) {
59
- this . cable . subscriptions . remove ( { channel : " CommentsChannel" } ) ;
64
+ this . cable . subscriptions . remove ( { channel : ' CommentsChannel' } ) ;
60
65
}
61
66
62
67
refreshComments ( ) {
@@ -75,6 +80,7 @@ class CommentBox extends BaseComponent {
75
80
} ;
76
81
const locale = data . get ( 'locale' ) || defaultLocale ;
77
82
83
+ /* eslint-disable no-script-url */
78
84
return (
79
85
< div className = "commentBox container" >
80
86
< h2 >
@@ -84,11 +90,11 @@ class CommentBox extends BaseComponent {
84
90
{ SelectLanguage ( actions . setLocale , locale ) }
85
91
< ul >
86
92
< li >
87
- { data . get ( 'isFetching' ) && < br /> ||
88
- < a href = "javascript:void(0)" onClick = { this . refreshComments } >
89
- { formatMessage ( defaultMessages . descriptionForceRefrech ) }
90
- </ a >
91
- }
93
+ { ( data . get ( 'isFetching' ) && < br /> ) ||
94
+ < a href = "javascript:void(0)" onClick = { this . refreshComments } >
95
+ { formatMessage ( defaultMessages . descriptionForceRefrech ) }
96
+ </ a >
97
+ }
92
98
</ li >
93
99
< li > { formatMessage ( defaultMessages . descriptionSupportMarkdown ) } </ li >
94
100
< li > { formatMessage ( defaultMessages . descriptionDeleteRule ) } </ li >
0 commit comments