mirror of
https://framagit.org/tykayn/mastodon.git
synced 2023-08-25 08:33:12 +02:00
Switch to compose route when replying and compose is not mounted
This commit is contained in:
parent
93577f74e7
commit
d32e0364f9
@ -19,6 +19,9 @@ export const COMPOSE_SUGGESTIONS_CLEAR = 'COMPOSE_SUGGESTIONS_CLEAR';
|
||||
export const COMPOSE_SUGGESTIONS_READY = 'COMPOSE_SUGGESTIONS_READY';
|
||||
export const COMPOSE_SUGGESTION_SELECT = 'COMPOSE_SUGGESTION_SELECT';
|
||||
|
||||
export const COMPOSE_MOUNT = 'COMPOSE_MOUNT';
|
||||
export const COMPOSE_UNMOUNT = 'COMPOSE_UNMOUNT';
|
||||
|
||||
export function changeCompose(text) {
|
||||
return {
|
||||
type: COMPOSE_CHANGE,
|
||||
@ -26,10 +29,16 @@ export function changeCompose(text) {
|
||||
};
|
||||
};
|
||||
|
||||
export function replyCompose(status) {
|
||||
return {
|
||||
type: COMPOSE_REPLY,
|
||||
status: status
|
||||
export function replyCompose(status, router) {
|
||||
return (dispatch, getState) => {
|
||||
dispatch({
|
||||
type: COMPOSE_REPLY,
|
||||
status: status
|
||||
});
|
||||
|
||||
if (!getState().getIn(['compose', 'mounted'])) {
|
||||
router.push('/statuses/new');
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@ -176,3 +185,15 @@ export function selectComposeSuggestion(position, accountId) {
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
export function mountCompose() {
|
||||
return {
|
||||
type: COMPOSE_MOUNT
|
||||
};
|
||||
};
|
||||
|
||||
export function unmountCompose() {
|
||||
return {
|
||||
type: COMPOSE_UNMOUNT
|
||||
};
|
||||
};
|
||||
|
@ -13,6 +13,11 @@ const messages = defineMessages({
|
||||
});
|
||||
|
||||
const StatusActionBar = React.createClass({
|
||||
|
||||
contextTypes: {
|
||||
router: React.PropTypes.object
|
||||
},
|
||||
|
||||
propTypes: {
|
||||
status: ImmutablePropTypes.map.isRequired,
|
||||
onReply: React.PropTypes.func,
|
||||
@ -25,7 +30,7 @@ const StatusActionBar = React.createClass({
|
||||
mixins: [PureRenderMixin],
|
||||
|
||||
handleReplyClick () {
|
||||
this.props.onReply(this.props.status);
|
||||
this.props.onReply(this.props.status, this.context.router);
|
||||
},
|
||||
|
||||
handleFavouriteClick () {
|
||||
|
@ -61,8 +61,8 @@ const makeMapStateToPropsLast = () => {
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
|
||||
onReply (status) {
|
||||
dispatch(replyCompose(status));
|
||||
onReply (status, router) {
|
||||
dispatch(replyCompose(status, router));
|
||||
},
|
||||
|
||||
onReblog (status) {
|
||||
|
@ -1,12 +1,13 @@
|
||||
import Drawer from './components/drawer';
|
||||
import Drawer from './components/drawer';
|
||||
import ComposeFormContainer from './containers/compose_form_container';
|
||||
import UploadFormContainer from './containers/upload_form_container';
|
||||
import NavigationContainer from './containers/navigation_container';
|
||||
import PureRenderMixin from 'react-addons-pure-render-mixin';
|
||||
import UploadFormContainer from './containers/upload_form_container';
|
||||
import NavigationContainer from './containers/navigation_container';
|
||||
import PureRenderMixin from 'react-addons-pure-render-mixin';
|
||||
import SuggestionsContainer from './containers/suggestions_container';
|
||||
import SearchContainer from './containers/search_container';
|
||||
import SearchContainer from './containers/search_container';
|
||||
import { fetchSuggestions } from '../../actions/suggestions';
|
||||
import { connect } from 'react-redux';
|
||||
import { connect } from 'react-redux';
|
||||
import { mountCompose, unmountCompose } from '../../actions/compose';
|
||||
|
||||
const Compose = React.createClass({
|
||||
|
||||
@ -17,9 +18,14 @@ const Compose = React.createClass({
|
||||
mixins: [PureRenderMixin],
|
||||
|
||||
componentDidMount () {
|
||||
this.props.dispatch(mountCompose());
|
||||
this.props.dispatch(fetchSuggestions());
|
||||
},
|
||||
|
||||
componentWillUnmount () {
|
||||
this.props.dispatch(unmountCompose());
|
||||
},
|
||||
|
||||
render () {
|
||||
return (
|
||||
<Drawer>
|
||||
|
@ -38,6 +38,9 @@ const makeMapStateToProps = () => {
|
||||
};
|
||||
|
||||
const Status = React.createClass({
|
||||
contextTypes: {
|
||||
router: React.PropTypes.object
|
||||
},
|
||||
|
||||
propTypes: {
|
||||
params: React.PropTypes.object.isRequired,
|
||||
@ -64,7 +67,7 @@ const Status = React.createClass({
|
||||
},
|
||||
|
||||
handleReplyClick (status) {
|
||||
this.props.dispatch(replyCompose(status));
|
||||
this.props.dispatch(replyCompose(status, this.context.router));
|
||||
},
|
||||
|
||||
handleReblogClick (status) {
|
||||
|
@ -1,4 +1,6 @@
|
||||
import {
|
||||
COMPOSE_MOUNT,
|
||||
COMPOSE_UNMOUNT,
|
||||
COMPOSE_CHANGE,
|
||||
COMPOSE_REPLY,
|
||||
COMPOSE_REPLY_CANCEL,
|
||||
@ -20,6 +22,7 @@ import { ACCOUNT_SET_SELF } from '../actions/accounts';
|
||||
import Immutable from 'immutable';
|
||||
|
||||
const initialState = Immutable.Map({
|
||||
mounted: false,
|
||||
text: '',
|
||||
in_reply_to: null,
|
||||
is_submitting: false,
|
||||
@ -80,6 +83,10 @@ const insertSuggestion = (state, position, completion) => {
|
||||
|
||||
export default function compose(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
case COMPOSE_MOUNT:
|
||||
return state.set('mounted', true);
|
||||
case COMPOSE_UNMOUNT:
|
||||
return state.set('mounted', false);
|
||||
case COMPOSE_CHANGE:
|
||||
return state.set('text', action.text);
|
||||
case COMPOSE_REPLY:
|
||||
|
Loading…
Reference in New Issue
Block a user