]>
cat aescling's git repositories - mastodon.git/blob - app/javascript/mastodon/containers/status_container.js
1 import React
from 'react' ;
2 import { connect
} from 'react-redux' ;
3 import Status
from '../components/status' ;
4 import { makeGetStatus
} from '../selectors' ;
9 } from '../actions/compose' ;
19 } from '../actions/interactions' ;
27 } from '../actions/statuses' ;
31 } from '../actions/accounts' ;
35 } from '../actions/domain_blocks' ;
36 import { initMuteModal
} from '../actions/mutes' ;
37 import { initBlockModal
} from '../actions/blocks' ;
38 import { initReport
} from '../actions/reports' ;
39 import { openModal
} from '../actions/modal' ;
40 import { defineMessages
, injectIntl
, FormattedMessage
} from 'react-intl' ;
41 import { boostModal
, deleteModal
} from '../initial_state' ;
42 import { showAlertForError
} from '../actions/alerts' ;
44 const messages
= defineMessages ({
45 deleteConfirm : { id : 'confirmations.delete.confirm' , defaultMessage : 'Delete' },
46 deleteMessage : { id : 'confirmations.delete.message' , defaultMessage : 'Are you sure you want to delete this status?' },
47 redraftConfirm : { id : 'confirmations.redraft.confirm' , defaultMessage : 'Delete & redraft' },
48 redraftMessage : { id : 'confirmations.redraft.message' , defaultMessage : 'Are you sure you want to delete this status and re-draft it? Favourites and boosts will be lost, and replies to the original post will be orphaned.' },
49 replyConfirm : { id : 'confirmations.reply.confirm' , defaultMessage : 'Reply' },
50 replyMessage : { id : 'confirmations.reply.message' , defaultMessage : 'Replying now will overwrite the message you are currently composing. Are you sure you want to proceed?' },
51 blockDomainConfirm : { id : 'confirmations.domain_block.confirm' , defaultMessage : 'Hide entire domain' },
54 const makeMapStateToProps
= () => {
55 const getStatus
= makeGetStatus ();
57 const mapStateToProps
= ( state
, props
) => ({
58 status : getStatus ( state
, props
),
61 return mapStateToProps
;
64 const mapDispatchToProps
= ( dispatch
, { intl
}) => ({
66 onReply ( status
, router
) {
67 dispatch (( _
, getState
) => {
68 let state
= getState ();
70 if ( state
. getIn ([ 'compose' , 'text' ]). trim (). length
!== 0 ) {
71 dispatch ( openModal ( 'CONFIRM' , {
72 message : intl
. formatMessage ( messages
. replyMessage
),
73 confirm : intl
. formatMessage ( messages
. replyConfirm
),
74 onConfirm : () => dispatch ( replyCompose ( status
, router
)),
77 dispatch ( replyCompose ( status
, router
));
82 onModalReblog ( status
) {
83 if ( status
. get ( 'reblogged' )) {
84 dispatch ( unreblog ( status
));
86 dispatch ( reblog ( status
));
90 onReblog ( status
, e
) {
91 if (( e
&& e
. shiftKey
) || ! boostModal
) {
92 this . onModalReblog ( status
);
94 dispatch ( openModal ( 'BOOST' , { status
, onReblog : this . onModalReblog
}));
98 onFavourite ( status
) {
99 if ( status
. get ( 'favourited' )) {
100 dispatch ( unfavourite ( status
));
102 dispatch ( favourite ( status
));
106 onBookmark ( status
) {
107 if ( status
. get ( 'bookmarked' )) {
108 dispatch ( unbookmark ( status
));
110 dispatch ( bookmark ( status
));
115 if ( status
. get ( 'pinned' )) {
116 dispatch ( unpin ( status
));
118 dispatch ( pin ( status
));
123 dispatch ( openModal ( 'EMBED' , {
124 url : status
. get ( 'url' ),
125 onError : error
=> dispatch ( showAlertForError ( error
)),
129 onDelete ( status
, history
, withRedraft
= false ) {
131 dispatch ( deleteStatus ( status
. get ( 'id' ), history
, withRedraft
));
133 dispatch ( openModal ( 'CONFIRM' , {
134 message : intl
. formatMessage ( withRedraft
? messages
. redraftMessage : messages
. deleteMessage
),
135 confirm : intl
. formatMessage ( withRedraft
? messages
. redraftConfirm : messages
. deleteConfirm
),
136 onConfirm : () => dispatch ( deleteStatus ( status
. get ( 'id' ), history
, withRedraft
)),
141 onDirect ( account
, router
) {
142 dispatch ( directCompose ( account
, router
));
145 onMention ( account
, router
) {
146 dispatch ( mentionCompose ( account
, router
));
149 onOpenMedia ( media
, index
) {
150 dispatch ( openModal ( 'MEDIA' , { media
, index
}));
153 onOpenVideo ( media
, time
) {
154 dispatch ( openModal ( 'VIDEO' , { media
, time
}));
158 const account
= status
. get ( 'account' );
159 dispatch ( initBlockModal ( account
));
162 onUnblock ( account
) {
163 dispatch ( unblockAccount ( account
. get ( 'id' )));
167 dispatch ( initReport ( status
. get ( 'account' ), status
));
171 dispatch ( initMuteModal ( account
));
175 dispatch ( unmuteAccount ( account
. get ( 'id' )));
178 onMuteConversation ( status
) {
179 if ( status
. get ( 'muted' )) {
180 dispatch ( unmuteStatus ( status
. get ( 'id' )));
182 dispatch ( muteStatus ( status
. get ( 'id' )));
186 onToggleHidden ( status
) {
187 if ( status
. get ( 'hidden' )) {
188 dispatch ( revealStatus ( status
. get ( 'id' )));
190 dispatch ( hideStatus ( status
. get ( 'id' )));
194 onToggleCollapsed ( status
, isCollapsed
) {
195 dispatch ( toggleStatusCollapse ( status
. get ( 'id' ), isCollapsed
));
198 onBlockDomain ( domain
) {
199 dispatch ( openModal ( 'CONFIRM' , {
200 message : < FormattedMessage id
= 'confirmations.domain_block.message' defaultMessage
= 'Are you really, really sure you want to block the entire {domain}? In most cases a few targeted blocks or mutes are sufficient and preferable. You will not see content from that domain in any public timelines or your notifications. Your followers from that domain will be removed.' values
={{ domain : < strong
>{ domain
}</ strong
> }} />,
201 confirm : intl
. formatMessage ( messages
. blockDomainConfirm
),
202 onConfirm : () => dispatch ( blockDomain ( domain
)),
206 onUnblockDomain ( domain
) {
207 dispatch ( unblockDomain ( domain
));
212 export default injectIntl ( connect ( makeMapStateToProps
, mapDispatchToProps
)( Status
));
This page took 0.114892 seconds and 5 git commands to generate.