watch emoticon autoreplace setting
This commit is contained in:
parent
c97d1d5b05
commit
91d593cb71
1 changed files with 11 additions and 3 deletions
|
@ -90,6 +90,7 @@ export default class BasicMessageEditor extends React.Component {
|
||||||
this._modifiedFlag = false;
|
this._modifiedFlag = false;
|
||||||
this._isIMEComposing = false;
|
this._isIMEComposing = false;
|
||||||
this._hasTextSelected = false;
|
this._hasTextSelected = false;
|
||||||
|
this._emoticonSettingHandle = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
_replaceEmoticon = (caretPosition, inputType, diff) => {
|
_replaceEmoticon = (caretPosition, inputType, diff) => {
|
||||||
|
@ -437,18 +438,25 @@ export default class BasicMessageEditor extends React.Component {
|
||||||
this.setState({completionIndex});
|
this.setState({completionIndex});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_configureEmoticonAutoReplace() {
|
||||||
|
const shouldReplace = SettingsStore.getValue('MessageComposerInput.autoReplaceEmoji');
|
||||||
|
this.props.model.setTransformCallback(shouldReplace ? this._replaceEmoticon : null);
|
||||||
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
this._editorRef.removeEventListener("input", this._onInput, true);
|
this._editorRef.removeEventListener("input", this._onInput, true);
|
||||||
this._editorRef.removeEventListener("compositionstart", this._onCompositionStart, true);
|
this._editorRef.removeEventListener("compositionstart", this._onCompositionStart, true);
|
||||||
this._editorRef.removeEventListener("compositionend", this._onCompositionEnd, true);
|
this._editorRef.removeEventListener("compositionend", this._onCompositionEnd, true);
|
||||||
|
SettingsStore.unwatchSetting(this._emoticonSettingHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const model = this.props.model;
|
const model = this.props.model;
|
||||||
model.setUpdateCallback(this._updateEditorState);
|
model.setUpdateCallback(this._updateEditorState);
|
||||||
if (SettingsStore.getValue('MessageComposerInput.autoReplaceEmoji')) {
|
this._emoticonSettingHandle = SettingsStore.watchSetting('MessageComposerInput.autoReplaceEmoji', null, () => {
|
||||||
model.setTransformCallback(this._replaceEmoticon);
|
this._configureEmoticonAutoReplace();
|
||||||
}
|
});
|
||||||
|
this._configureEmoticonAutoReplace();
|
||||||
const partCreator = model.partCreator;
|
const partCreator = model.partCreator;
|
||||||
// TODO: does this allow us to get rid of EditorStateTransfer?
|
// TODO: does this allow us to get rid of EditorStateTransfer?
|
||||||
// not really, but we could not serialize the parts, and just change the autoCompleter
|
// not really, but we could not serialize the parts, and just change the autoCompleter
|
||||||
|
|
Loading…
Reference in a new issue