]>
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
, makeGetPictureInPicture
} 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 { initBoostModal
} from '../actions/boosts' ;
39 import { initReport
} from '../actions/reports' ;
40 import { openModal
} from '../actions/modal' ;
41 import { deployPictureInPicture
} from '../actions/picture_in_picture' ;
42 import { defineMessages
, injectIntl
, FormattedMessage
} from 'react-intl' ;
43 import { boostModal
, deleteModal
} from '../initial_state' ;
44 import { showAlertForError
} from '../actions/alerts' ;
46 const messages
= defineMessages ({
47 deleteConfirm : { id : 'confirmations.delete.confirm' , defaultMessage : 'Delete' },
48 deleteMessage : { id : 'confirmations.delete.message' , defaultMessage : 'Are you sure you want to delete this status?' },
49 redraftConfirm : { id : 'confirmations.redraft.confirm' , defaultMessage : 'Delete & redraft' },
50 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.' },
51 replyConfirm : { id : 'confirmations.reply.confirm' , defaultMessage : 'Reply' },
52 replyMessage : { id : 'confirmations.reply.message' , defaultMessage : 'Replying now will overwrite the message you are currently composing. Are you sure you want to proceed?' },
53 blockDomainConfirm : { id : 'confirmations.domain_block.confirm' , defaultMessage : 'Hide entire domain' },
56 const makeMapStateToProps
= () => {
57 const getStatus
= makeGetStatus ();
58 const getPictureInPicture
= makeGetPictureInPicture ();
60 const mapStateToProps
= ( state
, props
) => ({
61 status : getStatus ( state
, props
),
62 pictureInPicture : getPictureInPicture ( state
, props
),
65 return mapStateToProps
;
68 const mapDispatchToProps
= ( dispatch
, { intl
}) => ({
70 onReply ( status
, router
) {
71 dispatch (( _
, getState
) => {
72 let state
= getState ();
74 if ( state
. getIn ([ 'compose' , 'text' ]). trim (). length
!== 0 ) {
75 dispatch ( openModal ( 'CONFIRM' , {
76 message : intl
. formatMessage ( messages
. replyMessage
),
77 confirm : intl
. formatMessage ( messages
. replyConfirm
),
78 onConfirm : () => dispatch ( replyCompose ( status
, router
)),
81 dispatch ( replyCompose ( status
, router
));
86 onModalReblog ( status
, privacy
) {
87 if ( status
. get ( 'reblogged' )) {
88 dispatch ( unreblog ( status
));
90 dispatch ( reblog ( status
, privacy
));
94 onReblog ( status
, e
) {
95 if (( e
&& e
. shiftKey
) || ! boostModal
) {
96 this . onModalReblog ( status
);
98 dispatch ( initBoostModal ({ status
, onReblog : this . onModalReblog
}));
102 onFavourite ( status
) {
103 if ( status
. get ( 'favourited' )) {
104 dispatch ( unfavourite ( status
));
106 dispatch ( favourite ( status
));
110 onBookmark ( status
) {
111 if ( status
. get ( 'bookmarked' )) {
112 dispatch ( unbookmark ( status
));
114 dispatch ( bookmark ( status
));
119 if ( status
. get ( 'pinned' )) {
120 dispatch ( unpin ( status
));
122 dispatch ( pin ( status
));
127 dispatch ( openModal ( 'EMBED' , {
128 url : status
. get ( 'url' ),
129 onError : error
=> dispatch ( showAlertForError ( error
)),
133 onDelete ( status
, history
, withRedraft
= false ) {
135 dispatch ( deleteStatus ( status
. get ( 'id' ), history
, withRedraft
));
137 dispatch ( openModal ( 'CONFIRM' , {
138 message : intl
. formatMessage ( withRedraft
? messages
. redraftMessage : messages
. deleteMessage
),
139 confirm : intl
. formatMessage ( withRedraft
? messages
. redraftConfirm : messages
. deleteConfirm
),
140 onConfirm : () => dispatch ( deleteStatus ( status
. get ( 'id' ), history
, withRedraft
)),
145 onDirect ( account
, router
) {
146 dispatch ( directCompose ( account
, router
));
149 onMention ( account
, router
) {
150 dispatch ( mentionCompose ( account
, router
));
153 onOpenMedia ( statusId
, media
, index
) {
154 dispatch ( openModal ( 'MEDIA' , { statusId
, media
, index
}));
157 onOpenVideo ( statusId
, media
, options
) {
158 dispatch ( openModal ( 'VIDEO' , { statusId
, media
, options
}));
162 const account
= status
. get ( 'account' );
163 dispatch ( initBlockModal ( account
));
166 onUnblock ( account
) {
167 dispatch ( unblockAccount ( account
. get ( 'id' )));
171 dispatch ( initReport ( status
. get ( 'account' ), status
));
175 dispatch ( initMuteModal ( account
));
179 dispatch ( unmuteAccount ( account
. get ( 'id' )));
182 onMuteConversation ( status
) {
183 if ( status
. get ( 'muted' )) {
184 dispatch ( unmuteStatus ( status
. get ( 'id' )));
186 dispatch ( muteStatus ( status
. get ( 'id' )));
190 onToggleHidden ( status
) {
191 if ( status
. get ( 'hidden' )) {
192 dispatch ( revealStatus ( status
. get ( 'id' )));
194 dispatch ( hideStatus ( status
. get ( 'id' )));
198 onToggleCollapsed ( status
, isCollapsed
) {
199 dispatch ( toggleStatusCollapse ( status
. get ( 'id' ), isCollapsed
));
202 onBlockDomain ( domain
) {
203 dispatch ( openModal ( 'CONFIRM' , {
204 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
> }} />,
205 confirm : intl
. formatMessage ( messages
. blockDomainConfirm
),
206 onConfirm : () => dispatch ( blockDomain ( domain
)),
210 onUnblockDomain ( domain
) {
211 dispatch ( unblockDomain ( domain
));
214 deployPictureInPicture ( status
, type
, mediaProps
) {
215 dispatch ( deployPictureInPicture ( status
. get ( 'id' ), status
. getIn ([ 'account' , 'id' ]), type
, mediaProps
));
220 export default injectIntl ( connect ( makeMapStateToProps
, mapDispatchToProps
)( Status
));
This page took 0.169427 seconds and 4 git commands to generate.