forked from mastodon/mastodon
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change conversations UI (mastodon#11896)
Fix mastodon#11414, fix mastodon#9860, fix mastodon#10434
- Loading branch information
1 parent
5f57750
commit 501905a
Showing
6 changed files
with
280 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 65 additions & 10 deletions
75
app/javascript/mastodon/features/direct_timeline/containers/conversation_container.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,74 @@ | ||
import { connect } from 'react-redux'; | ||
import Conversation from '../components/conversation'; | ||
import { markConversationRead } from '../../../actions/conversations'; | ||
import { markConversationRead, deleteConversation } from 'mastodon/actions/conversations'; | ||
import { makeGetStatus } from 'mastodon/selectors'; | ||
import { replyCompose } from 'mastodon/actions/compose'; | ||
import { openModal } from 'mastodon/actions/modal'; | ||
import { muteStatus, unmuteStatus, hideStatus, revealStatus } from 'mastodon/actions/statuses'; | ||
import { defineMessages, injectIntl } from 'react-intl'; | ||
|
||
const mapStateToProps = (state, { conversationId }) => { | ||
const conversation = state.getIn(['conversations', 'items']).find(x => x.get('id') === conversationId); | ||
const messages = defineMessages({ | ||
replyConfirm: { id: 'confirmations.reply.confirm', defaultMessage: 'Reply' }, | ||
replyMessage: { id: 'confirmations.reply.message', defaultMessage: 'Replying now will overwrite the message you are currently composing. Are you sure you want to proceed?' }, | ||
}); | ||
|
||
const mapStateToProps = () => { | ||
const getStatus = makeGetStatus(); | ||
|
||
return (state, { conversationId }) => { | ||
const conversation = state.getIn(['conversations', 'items']).find(x => x.get('id') === conversationId); | ||
const lastStatusId = conversation.get('last_status', null); | ||
|
||
return { | ||
accounts: conversation.get('accounts').map(accountId => state.getIn(['accounts', accountId], null)), | ||
unread: conversation.get('unread'), | ||
lastStatusId: conversation.get('last_status', null), | ||
return { | ||
accounts: conversation.get('accounts').map(accountId => state.getIn(['accounts', accountId], null)), | ||
unread: conversation.get('unread'), | ||
lastStatus: lastStatusId && getStatus(state, { id: lastStatusId }), | ||
}; | ||
}; | ||
}; | ||
|
||
const mapDispatchToProps = (dispatch, { conversationId }) => ({ | ||
markRead: () => dispatch(markConversationRead(conversationId)), | ||
const mapDispatchToProps = (dispatch, { intl, conversationId }) => ({ | ||
|
||
markRead () { | ||
dispatch(markConversationRead(conversationId)); | ||
}, | ||
|
||
reply (status, router) { | ||
dispatch((_, getState) => { | ||
let state = getState(); | ||
|
||
if (state.getIn(['compose', 'text']).trim().length !== 0) { | ||
dispatch(openModal('CONFIRM', { | ||
message: intl.formatMessage(messages.replyMessage), | ||
confirm: intl.formatMessage(messages.replyConfirm), | ||
onConfirm: () => dispatch(replyCompose(status, router)), | ||
})); | ||
} else { | ||
dispatch(replyCompose(status, router)); | ||
} | ||
}); | ||
}, | ||
|
||
delete () { | ||
dispatch(deleteConversation(conversationId)); | ||
}, | ||
|
||
onMute (status) { | ||
if (status.get('muted')) { | ||
dispatch(unmuteStatus(status.get('id'))); | ||
} else { | ||
dispatch(muteStatus(status.get('id'))); | ||
} | ||
}, | ||
|
||
onToggleHidden (status) { | ||
if (status.get('hidden')) { | ||
dispatch(revealStatus(status.get('id'))); | ||
} else { | ||
dispatch(hideStatus(status.get('id'))); | ||
} | ||
}, | ||
|
||
}); | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(Conversation); | ||
export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(Conversation)); |
Oops, something went wrong.