Merge pull request #311 from aviraldg/fix-rte-history

Use different keys for new MessageComposerInput
This commit is contained in:
David Baker 2016-06-16 10:16:41 +01:00 committed by GitHub
commit 721ae68aa4

View file

@ -139,7 +139,7 @@ export default class MessageComposerInput extends React.Component {
this.element = element; this.element = element;
this.position = -1; this.position = -1;
var storedData = window.sessionStorage.getItem( var storedData = window.sessionStorage.getItem(
"history_" + roomId "mx_messagecomposer_history_" + roomId
); );
if (storedData) { if (storedData) {
this.data = JSON.parse(storedData); this.data = JSON.parse(storedData);
@ -153,7 +153,7 @@ export default class MessageComposerInput extends React.Component {
// store a message in the sent history // store a message in the sent history
this.data.unshift(text); this.data.unshift(text);
window.sessionStorage.setItem( window.sessionStorage.setItem(
"history_" + this.roomId, "mx_messagecomposer_history_" + this.roomId,
JSON.stringify(this.data) JSON.stringify(this.data)
); );
// reset history position // reset history position
@ -200,11 +200,11 @@ export default class MessageComposerInput extends React.Component {
// NB: This isn't 'originalText' because we want to restore // NB: This isn't 'originalText' because we want to restore
// sent history items too! // sent history items too!
let contentJSON = JSON.stringify(convertToRaw(component.state.editorState.getCurrentContent())); let contentJSON = JSON.stringify(convertToRaw(component.state.editorState.getCurrentContent()));
window.sessionStorage.setItem("input_" + this.roomId, contentJSON); window.sessionStorage.setItem("mx_messagecomposer_input_" + this.roomId, contentJSON);
}, },
setLastTextEntry: function() { setLastTextEntry: function() {
let contentJSON = window.sessionStorage.getItem("input_" + this.roomId); let contentJSON = window.sessionStorage.getItem("mx_messagecomposer_input_" + this.roomId);
if (contentJSON) { if (contentJSON) {
let content = convertFromRaw(JSON.parse(contentJSON)); let content = convertFromRaw(JSON.parse(contentJSON));
component.setState({ component.setState({