Cancel edit message
This commit is contained in:
parent
32fdea3de1
commit
272f6acd70
|
@ -35,6 +35,7 @@ export const MESSAGES = createRequestTypes('MESSAGES', [
|
||||||
'DELETE_SUCCESS',
|
'DELETE_SUCCESS',
|
||||||
'DELETE_FAILURE',
|
'DELETE_FAILURE',
|
||||||
'EDIT_INIT',
|
'EDIT_INIT',
|
||||||
|
'EDIT_CANCEL',
|
||||||
'EDIT_REQUEST',
|
'EDIT_REQUEST',
|
||||||
'EDIT_SUCCESS',
|
'EDIT_SUCCESS',
|
||||||
'EDIT_FAILURE',
|
'EDIT_FAILURE',
|
||||||
|
|
|
@ -47,6 +47,12 @@ export function editInit(message) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function editCancel() {
|
||||||
|
return {
|
||||||
|
type: types.MESSAGES.EDIT_CANCEL
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export function editRequest(message) {
|
export function editRequest(message) {
|
||||||
return {
|
return {
|
||||||
type: types.MESSAGES.EDIT_REQUEST,
|
type: types.MESSAGES.EDIT_REQUEST,
|
||||||
|
|
|
@ -59,6 +59,8 @@ export default class MessageBox extends React.Component {
|
||||||
if (this.props.message !== nextProps.message && nextProps.message) {
|
if (this.props.message !== nextProps.message && nextProps.message) {
|
||||||
this.component.setNativeProps({ text: nextProps.message.msg });
|
this.component.setNativeProps({ text: nextProps.message.msg });
|
||||||
this.component.focus();
|
this.component.focus();
|
||||||
|
} else if (!nextProps.message) {
|
||||||
|
this.component.setNativeProps({ text: '' });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -118,12 +118,12 @@ export default class Message extends React.Component {
|
||||||
this.QUOTE_INDEX = this.options.length - 1;
|
this.QUOTE_INDEX = this.options.length - 1;
|
||||||
// Star
|
// Star
|
||||||
if (this.props.Message_AllowStarring) {
|
if (this.props.Message_AllowStarring) {
|
||||||
this.options.push('Star Message');
|
this.options.push('Star');
|
||||||
this.STAR_INDEX = this.options.length - 1;
|
this.STAR_INDEX = this.options.length - 1;
|
||||||
}
|
}
|
||||||
// Pin
|
// Pin
|
||||||
if (this.props.Message_AllowPinning) {
|
if (this.props.Message_AllowPinning) {
|
||||||
this.options.push('Pin Message');
|
this.options.push('Pin');
|
||||||
this.PIN_INDEX = this.options.length - 1;
|
this.PIN_INDEX = this.options.length - 1;
|
||||||
}
|
}
|
||||||
// Delete
|
// Delete
|
||||||
|
|
|
@ -33,6 +33,12 @@ export default function messages(state = initialState, action) {
|
||||||
message: action.message,
|
message: action.message,
|
||||||
editing: true
|
editing: true
|
||||||
};
|
};
|
||||||
|
case types.MESSAGES.EDIT_CANCEL:
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
message: {},
|
||||||
|
editing: false
|
||||||
|
};
|
||||||
case types.MESSAGES.EDIT_SUCCESS:
|
case types.MESSAGES.EDIT_SUCCESS:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
|
|
|
@ -7,6 +7,7 @@ import { bindActionCreators } from 'redux';
|
||||||
|
|
||||||
import * as actions from '../actions';
|
import * as actions from '../actions';
|
||||||
import { openRoom } from '../actions/room';
|
import { openRoom } from '../actions/room';
|
||||||
|
import { editCancel } from '../actions/messages';
|
||||||
import realm from '../lib/realm';
|
import realm from '../lib/realm';
|
||||||
import RocketChat from '../lib/rocketchat';
|
import RocketChat from '../lib/rocketchat';
|
||||||
import Message from '../containers/message';
|
import Message from '../containers/message';
|
||||||
|
@ -59,13 +60,15 @@ const styles = StyleSheet.create({
|
||||||
}),
|
}),
|
||||||
dispatch => ({
|
dispatch => ({
|
||||||
actions: bindActionCreators(actions, dispatch),
|
actions: bindActionCreators(actions, dispatch),
|
||||||
openRoom: room => dispatch(openRoom(room))
|
openRoom: room => dispatch(openRoom(room)),
|
||||||
|
editCancel: () => dispatch(editCancel())
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
export default class RoomView extends React.Component {
|
export default class RoomView extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
navigation: PropTypes.object.isRequired,
|
navigation: PropTypes.object.isRequired,
|
||||||
openRoom: PropTypes.func.isRequired,
|
openRoom: PropTypes.func.isRequired,
|
||||||
|
editCancel: PropTypes.func,
|
||||||
rid: PropTypes.string,
|
rid: PropTypes.string,
|
||||||
sid: PropTypes.string,
|
sid: PropTypes.string,
|
||||||
name: PropTypes.string,
|
name: PropTypes.string,
|
||||||
|
@ -132,6 +135,7 @@ export default class RoomView extends React.Component {
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
clearTimeout(this.timer);
|
clearTimeout(this.timer);
|
||||||
this.data.removeAllListeners();
|
this.data.removeAllListeners();
|
||||||
|
this.props.editCancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
onEndReached = () => {
|
onEndReached = () => {
|
||||||
|
|
Loading…
Reference in New Issue