change Composer placeholder text based on replying/rich quoting state
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>pull/21833/head
parent
47d4e5f8d1
commit
05434e782a
|
@ -21,7 +21,7 @@ import MatrixClientPeg from '../../../MatrixClientPeg';
|
||||||
import Modal from '../../../Modal';
|
import Modal from '../../../Modal';
|
||||||
import sdk from '../../../index';
|
import sdk from '../../../index';
|
||||||
import dis from '../../../dispatcher';
|
import dis from '../../../dispatcher';
|
||||||
import Autocomplete from './Autocomplete';
|
import RoomViewStore from '../../../stores/RoomViewStore';
|
||||||
import SettingsStore, {SettingLevel} from "../../../settings/SettingsStore";
|
import SettingsStore, {SettingLevel} from "../../../settings/SettingsStore";
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,6 +42,7 @@ export default class MessageComposer extends React.Component {
|
||||||
this.onToggleMarkdownClicked = this.onToggleMarkdownClicked.bind(this);
|
this.onToggleMarkdownClicked = this.onToggleMarkdownClicked.bind(this);
|
||||||
this.onInputStateChanged = this.onInputStateChanged.bind(this);
|
this.onInputStateChanged = this.onInputStateChanged.bind(this);
|
||||||
this.onEvent = this.onEvent.bind(this);
|
this.onEvent = this.onEvent.bind(this);
|
||||||
|
this._onRoomViewStoreUpdate = this._onRoomViewStoreUpdate.bind(this);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
autocompleteQuery: '',
|
autocompleteQuery: '',
|
||||||
|
@ -53,6 +54,7 @@ export default class MessageComposer extends React.Component {
|
||||||
wordCount: 0,
|
wordCount: 0,
|
||||||
},
|
},
|
||||||
showFormatting: SettingsStore.getValue('MessageComposer.showFormatting'),
|
showFormatting: SettingsStore.getValue('MessageComposer.showFormatting'),
|
||||||
|
isQuoting: Boolean(RoomViewStore.getQuotingEvent()),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,12 +64,16 @@ export default class MessageComposer extends React.Component {
|
||||||
// marked as encrypted.
|
// marked as encrypted.
|
||||||
// XXX: fragile as all hell - fixme somehow, perhaps with a dedicated Room.encryption event or something.
|
// XXX: fragile as all hell - fixme somehow, perhaps with a dedicated Room.encryption event or something.
|
||||||
MatrixClientPeg.get().on("event", this.onEvent);
|
MatrixClientPeg.get().on("event", this.onEvent);
|
||||||
|
this._roomStoreToken = RoomViewStore.addListener(this._onRoomViewStoreUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
if (MatrixClientPeg.get()) {
|
if (MatrixClientPeg.get()) {
|
||||||
MatrixClientPeg.get().removeListener("event", this.onEvent);
|
MatrixClientPeg.get().removeListener("event", this.onEvent);
|
||||||
}
|
}
|
||||||
|
if (this._roomStoreToken) {
|
||||||
|
this._roomStoreToken.remove();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onEvent(event) {
|
onEvent(event) {
|
||||||
|
@ -76,6 +82,12 @@ export default class MessageComposer extends React.Component {
|
||||||
this.forceUpdate();
|
this.forceUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_onRoomViewStoreUpdate() {
|
||||||
|
const isQuoting = Boolean(RoomViewStore.getQuotingEvent());
|
||||||
|
if (this.state.isQuoting === isQuoting) return;
|
||||||
|
this.setState({ isQuoting });
|
||||||
|
}
|
||||||
|
|
||||||
onUploadClick(ev) {
|
onUploadClick(ev) {
|
||||||
if (MatrixClientPeg.get().isGuest()) {
|
if (MatrixClientPeg.get().isGuest()) {
|
||||||
dis.dispatch({action: 'view_set_mxid'});
|
dis.dispatch({action: 'view_set_mxid'});
|
||||||
|
@ -325,8 +337,20 @@ export default class MessageComposer extends React.Component {
|
||||||
key="controls_formatting" />
|
key="controls_formatting" />
|
||||||
);
|
);
|
||||||
|
|
||||||
const placeholderText = roomIsEncrypted ?
|
let placeholderText;
|
||||||
_t('Send an encrypted message') + '…' : _t('Send a message (unencrypted)') + '…';
|
if (this.state.isQuoting) {
|
||||||
|
if (roomIsEncrypted) {
|
||||||
|
placeholderText = _t('Send an encrypted reply');
|
||||||
|
} else {
|
||||||
|
placeholderText = _t('Send a reply (unencrypted)');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (roomIsEncrypted) {
|
||||||
|
placeholderText = _t('Send an encrypted message');
|
||||||
|
} else {
|
||||||
|
placeholderText = _t('Send a message (unencrypted)');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
controls.push(
|
controls.push(
|
||||||
<MessageComposerInput
|
<MessageComposerInput
|
||||||
|
@ -334,7 +358,7 @@ export default class MessageComposer extends React.Component {
|
||||||
key="controls_input"
|
key="controls_input"
|
||||||
onResize={this.props.onResize}
|
onResize={this.props.onResize}
|
||||||
room={this.props.room}
|
room={this.props.room}
|
||||||
placeholder={placeholderText}
|
placeholder={placeholderText + '…'}
|
||||||
onFilesPasted={this.uploadFiles}
|
onFilesPasted={this.uploadFiles}
|
||||||
onContentChanged={this.onInputContentChanged}
|
onContentChanged={this.onInputContentChanged}
|
||||||
onInputStateChanged={this.onInputStateChanged} />,
|
onInputStateChanged={this.onInputStateChanged} />,
|
||||||
|
|
|
@ -298,7 +298,9 @@
|
||||||
"Upload file": "Upload file",
|
"Upload file": "Upload file",
|
||||||
"Show Text Formatting Toolbar": "Show Text Formatting Toolbar",
|
"Show Text Formatting Toolbar": "Show Text Formatting Toolbar",
|
||||||
"Send an encrypted message": "Send an encrypted message",
|
"Send an encrypted message": "Send an encrypted message",
|
||||||
|
"Send an encrypted reply": "Send an encrypted reply",
|
||||||
"Send a message (unencrypted)": "Send a message (unencrypted)",
|
"Send a message (unencrypted)": "Send a message (unencrypted)",
|
||||||
|
"Send a reply (unencrypted)": "Send a reply (unencrypted)",
|
||||||
"You do not have permission to post to this room": "You do not have permission to post to this room",
|
"You do not have permission to post to this room": "You do not have permission to post to this room",
|
||||||
"Turn Markdown on": "Turn Markdown on",
|
"Turn Markdown on": "Turn Markdown on",
|
||||||
"Turn Markdown off": "Turn Markdown off",
|
"Turn Markdown off": "Turn Markdown off",
|
||||||
|
|
Loading…
Reference in New Issue