]>
cat aescling's git repositories - mastodon.git/blob - app/javascript/flavours/glitch/features/community_timeline/index.js
1 import React
from 'react' ;
2 import { connect
} from 'react-redux' ;
3 import PropTypes
from 'prop-types' ;
4 import StatusListContainer
from 'flavours/glitch/features/ui/containers/status_list_container' ;
5 import Column
from 'flavours/glitch/components/column' ;
6 import ColumnHeader
from 'flavours/glitch/components/column_header' ;
7 import { expandCommunityTimeline
} from 'flavours/glitch/actions/timelines' ;
8 import { addColumn
, removeColumn
, moveColumn
} from 'flavours/glitch/actions/columns' ;
9 import { defineMessages
, injectIntl
, FormattedMessage
} from 'react-intl' ;
10 import ColumnSettingsContainer
from './containers/column_settings_container' ;
11 import { connectCommunityStream
} from 'flavours/glitch/actions/streaming' ;
13 const messages
= defineMessages ({
14 title : { id : 'column.community' , defaultMessage : 'Local timeline' },
17 const mapStateToProps
= state
=> ({
18 hasUnread : state
. getIn ([ 'timelines' , 'community' , 'unread' ]) > 0 ,
21 @ connect ( mapStateToProps
)
23 export default class CommunityTimeline
extends React
. PureComponent
{
26 dispatch : PropTypes
. func
. isRequired
,
27 columnId : PropTypes
. string
,
28 intl : PropTypes
. object
. isRequired
,
29 hasUnread : PropTypes
. bool
,
30 multiColumn : PropTypes
. bool
,
34 const { columnId
, dispatch
} = this . props
;
37 dispatch ( removeColumn ( columnId
));
39 dispatch ( addColumn ( 'COMMUNITY' , {}));
43 handleMove
= ( dir
) => {
44 const { columnId
, dispatch
} = this . props
;
45 dispatch ( moveColumn ( columnId
, dir
));
48 handleHeaderClick
= () => {
49 this . column
. scrollTop ();
52 componentDidMount () {
53 const { dispatch
} = this . props
;
55 dispatch ( expandCommunityTimeline ());
56 this . disconnect
= dispatch ( connectCommunityStream ());
59 componentWillUnmount () {
60 if ( this . disconnect
) {
62 this . disconnect
= null ;
70 handleLoadMore
= maxId
=> {
71 this . props
. dispatch ( expandCommunityTimeline ({ maxId
}));
75 const { intl
, hasUnread
, columnId
, multiColumn
} = this . props
;
76 const pinned
= !! columnId
;
79 < Column ref
={ this . setRef
} name
= 'local' label
={ intl
. formatMessage ( messages
. title
)}>
83 title
={ intl
. formatMessage ( messages
. title
)}
84 onPin
={ this . handlePin
}
85 onMove
={ this . handleMove
}
86 onClick
={ this . handleHeaderClick
}
88 multiColumn
={ multiColumn
}
90 < ColumnSettingsContainer
/>
95 scrollKey
={ `community_timeline- ${columnId} ` }
96 timelineId
= 'community'
97 onLoadMore
={ this . handleLoadMore
}
98 emptyMessage
={< FormattedMessage id
= 'empty_column.community' defaultMessage
= 'The local timeline is empty. Write something publicly to get the ball rolling!' />}
This page took 0.075057 seconds and 4 git commands to generate.