Merge pull request #348 from nickago/MM-1550
Mm 1550 Mentions are no longer removed from auto complete once used
Этот коммит содержится в:
@@ -81,7 +81,7 @@ module.exports = React.createClass({
|
|||||||
this.setState({selectedMention: 0, selectedUsername: ''});
|
this.setState({selectedMention: 0, selectedUsername: ''});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onListenerChange: function(id, mentionText, excludeList) {
|
onListenerChange: function(id, mentionText) {
|
||||||
if (id !== this.props.id) {
|
if (id !== this.props.id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -90,9 +90,6 @@ module.exports = React.createClass({
|
|||||||
if (mentionText != null) {
|
if (mentionText != null) {
|
||||||
newState.mentionText = mentionText;
|
newState.mentionText = mentionText;
|
||||||
}
|
}
|
||||||
if (excludeList != null) {
|
|
||||||
newState.excludeUsers = excludeList;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setState(newState);
|
this.setState(newState);
|
||||||
},
|
},
|
||||||
@@ -149,15 +146,6 @@ module.exports = React.createClass({
|
|||||||
scrollTop: scrollAmount
|
scrollTop: scrollAmount
|
||||||
}, 75);
|
}, 75);
|
||||||
},
|
},
|
||||||
alreadyMentioned: function(username) {
|
|
||||||
var excludeUsers = this.state.excludeUsers;
|
|
||||||
for (var i = 0; i < excludeUsers.length; i++) {
|
|
||||||
if (excludeUsers[i] === username) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
getInitialState: function() {
|
getInitialState: function() {
|
||||||
return {excludeUsers: [], mentionText: '-1', selectedMention: 0, selectedUsername: ''};
|
return {excludeUsers: [], mentionText: '-1', selectedMention: 0, selectedUsername: ''};
|
||||||
},
|
},
|
||||||
@@ -201,9 +189,6 @@ module.exports = React.createClass({
|
|||||||
var index = 0;
|
var index = 0;
|
||||||
|
|
||||||
for (var i = 0; i < users.length && index < MAX_ITEMS_IN_LIST; i++) {
|
for (var i = 0; i < users.length && index < MAX_ITEMS_IN_LIST; i++) {
|
||||||
if (this.alreadyMentioned(users[i].username)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if ((users[i].first_name && users[i].first_name.lastIndexOf(mentionText, 0) === 0) ||
|
if ((users[i].first_name && users[i].first_name.lastIndexOf(mentionText, 0) === 0) ||
|
||||||
(users[i].last_name && users[i].last_name.lastIndexOf(mentionText, 0) === 0) ||
|
(users[i].last_name && users[i].last_name.lastIndexOf(mentionText, 0) === 0) ||
|
||||||
users[i].username.lastIndexOf(mentionText, 0) === 0) {
|
users[i].username.lastIndexOf(mentionText, 0) === 0) {
|
||||||
|
|||||||
@@ -2,11 +2,7 @@
|
|||||||
// See License.txt for license information.
|
// See License.txt for license information.
|
||||||
|
|
||||||
var AppDispatcher = require('../dispatcher/app_dispatcher.jsx');
|
var AppDispatcher = require('../dispatcher/app_dispatcher.jsx');
|
||||||
var UserStore = require('../stores/user_store.jsx');
|
|
||||||
var PostStore = require('../stores/post_store.jsx');
|
var PostStore = require('../stores/post_store.jsx');
|
||||||
var SocketStore = require('../stores/socket_store.jsx');
|
|
||||||
var MsgTyping = require('./msg_typing.jsx');
|
|
||||||
var MentionList = require('./mention_list.jsx');
|
|
||||||
var CommandList = require('./command_list.jsx');
|
var CommandList = require('./command_list.jsx');
|
||||||
var ErrorStore = require('../stores/error_store.jsx');
|
var ErrorStore = require('../stores/error_store.jsx');
|
||||||
var AsyncClient = require('../utils/async_client.jsx');
|
var AsyncClient = require('../utils/async_client.jsx');
|
||||||
@@ -19,53 +15,53 @@ function getStateFromStores() {
|
|||||||
var error = ErrorStore.getLastError();
|
var error = ErrorStore.getLastError();
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
return { message: error.message };
|
return {message: error.message};
|
||||||
} else {
|
|
||||||
return { message: null };
|
|
||||||
}
|
}
|
||||||
|
return {message: null};
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = React.createClass({
|
module.exports = React.createClass({
|
||||||
|
displayName: 'Textbox',
|
||||||
caret: -1,
|
caret: -1,
|
||||||
addedMention: false,
|
addedMention: false,
|
||||||
doProcessMentions: false,
|
doProcessMentions: false,
|
||||||
mentions: [],
|
mentions: [],
|
||||||
componentDidMount: function() {
|
componentDidMount: function() {
|
||||||
PostStore.addAddMentionListener(this._onChange);
|
PostStore.addAddMentionListener(this.onListenerChange);
|
||||||
ErrorStore.addChangeListener(this._onError);
|
ErrorStore.addChangeListener(this.onRecievedError);
|
||||||
|
|
||||||
this.resize();
|
this.resize();
|
||||||
this.processMentions();
|
this.updateMentionTab(null);
|
||||||
},
|
},
|
||||||
componentWillUnmount: function() {
|
componentWillUnmount: function() {
|
||||||
PostStore.removeAddMentionListener(this._onChange);
|
PostStore.removeAddMentionListener(this.onListenerChange);
|
||||||
ErrorStore.removeChangeListener(this._onError);
|
ErrorStore.removeChangeListener(this.onRecievedError);
|
||||||
},
|
},
|
||||||
_onChange: function(id, username) {
|
onListenerChange: function(id, username) {
|
||||||
if (id !== this.props.id) return;
|
if (id === this.props.id) {
|
||||||
this.addMention(username);
|
this.addMention(username);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
_onError: function() {
|
onRecievedError: function() {
|
||||||
var errorState = getStateFromStores();
|
var errorState = getStateFromStores();
|
||||||
|
|
||||||
if (this.state.timerInterrupt != null) {
|
if (this.state.timerInterrupt != null) {
|
||||||
window.clearInterval(this.state.timerInterrupt);
|
window.clearInterval(this.state.timerInterrupt);
|
||||||
this.setState({ timerInterrupt: null });
|
this.setState({timerInterrupt: null});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (errorState.message === "There appears to be a problem with your internet connection") {
|
if (errorState.message === 'There appears to be a problem with your internet connection') {
|
||||||
this.setState({ connection: "bad-connection" });
|
this.setState({connection: 'bad-connection'});
|
||||||
var timerInterrupt = window.setInterval(this._onTimerInterrupt, 5000);
|
var timerInterrupt = window.setInterval(this.onTimerInterrupt, 5000);
|
||||||
this.setState({ timerInterrupt: timerInterrupt });
|
this.setState({timerInterrupt: timerInterrupt});
|
||||||
}
|
} else {
|
||||||
else {
|
this.setState({connection: ''});
|
||||||
this.setState({ connection: "" });
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_onTimerInterrupt: function() {
|
onTimerInterrupt: function() {
|
||||||
//Since these should only happen when you have no connection and slightly briefly after any
|
//Since these should only happen when you have no connection and slightly briefly after any
|
||||||
//performance hit should not matter
|
//performance hit should not matter
|
||||||
if (this.state.connection === "bad-connection") {
|
if (this.state.connection === 'bad-connection') {
|
||||||
AppDispatcher.handleServerAction({
|
AppDispatcher.handleServerAction({
|
||||||
type: ActionTypes.RECIEVED_ERROR,
|
type: ActionTypes.RECIEVED_ERROR,
|
||||||
err: null
|
err: null
|
||||||
@@ -75,15 +71,15 @@ module.exports = React.createClass({
|
|||||||
}
|
}
|
||||||
|
|
||||||
window.clearInterval(this.state.timerInterrupt);
|
window.clearInterval(this.state.timerInterrupt);
|
||||||
this.setState({ timerInterrupt: null });
|
this.setState({timerInterrupt: null});
|
||||||
},
|
},
|
||||||
componentDidUpdate: function() {
|
componentDidUpdate: function() {
|
||||||
if (this.caret >= 0) {
|
if (this.caret >= 0) {
|
||||||
utils.setCaretPosition(this.refs.message.getDOMNode(), this.caret)
|
utils.setCaretPosition(this.refs.message.getDOMNode(), this.caret);
|
||||||
this.caret = -1;
|
this.caret = -1;
|
||||||
}
|
}
|
||||||
if (this.doProcessMentions) {
|
if (this.doProcessMentions) {
|
||||||
this.processMentions();
|
this.updateMentionTab(null);
|
||||||
this.doProcessMentions = false;
|
this.doProcessMentions = false;
|
||||||
}
|
}
|
||||||
this.resize();
|
this.resize();
|
||||||
@@ -93,7 +89,7 @@ module.exports = React.createClass({
|
|||||||
this.checkForNewMention(nextProps.messageText);
|
this.checkForNewMention(nextProps.messageText);
|
||||||
}
|
}
|
||||||
var text = this.refs.message.getDOMNode().value;
|
var text = this.refs.message.getDOMNode().value;
|
||||||
if (nextProps.channelId != this.props.channelId || nextProps.messageText !== text) {
|
if (nextProps.channelId !== this.props.channelId || nextProps.messageText !== text) {
|
||||||
this.doProcessMentions = true;
|
this.doProcessMentions = true;
|
||||||
}
|
}
|
||||||
this.addedMention = false;
|
this.addedMention = false;
|
||||||
@@ -101,17 +97,17 @@ module.exports = React.createClass({
|
|||||||
this.resize();
|
this.resize();
|
||||||
},
|
},
|
||||||
getInitialState: function() {
|
getInitialState: function() {
|
||||||
return { mentionText: '-1', mentions: [], connection: "", timerInterrupt: null };
|
return {mentionText: '-1', mentions: [], connection: '', timerInterrupt: null};
|
||||||
},
|
},
|
||||||
updateMentionTab: function(mentionText, excludeList) {
|
updateMentionTab: function(mentionText) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
// using setTimeout so dispatch isn't called during an in progress dispatch
|
// using setTimeout so dispatch isn't called during an in progress dispatch
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
AppDispatcher.handleViewAction({
|
AppDispatcher.handleViewAction({
|
||||||
type: ActionTypes.RECIEVED_MENTION_DATA,
|
type: ActionTypes.RECIEVED_MENTION_DATA,
|
||||||
id: self.props.id,
|
id: self.props.id,
|
||||||
mention_text: mentionText,
|
mention_text: mentionText
|
||||||
exclude_list: excludeList
|
|
||||||
});
|
});
|
||||||
}, 1);
|
}, 1);
|
||||||
},
|
},
|
||||||
@@ -122,13 +118,13 @@ module.exports = React.createClass({
|
|||||||
handleKeyPress: function(e) {
|
handleKeyPress: function(e) {
|
||||||
var text = this.refs.message.getDOMNode().value;
|
var text = this.refs.message.getDOMNode().value;
|
||||||
|
|
||||||
if (!this.refs.commands.isEmpty() && text.indexOf("/") == 0 && e.which==13) {
|
if (!this.refs.commands.isEmpty() && text.indexOf('/') === 0 && e.which === 13) {
|
||||||
this.refs.commands.addFirstCommand();
|
this.refs.commands.addFirstCommand();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !this.doProcessMentions) {
|
if (!this.doProcessMentions) {
|
||||||
var caret = utils.getCaretPosition(this.refs.message.getDOMNode());
|
var caret = utils.getCaretPosition(this.refs.message.getDOMNode());
|
||||||
var preText = text.substring(0, caret);
|
var preText = text.substring(0, caret);
|
||||||
var lastSpace = preText.lastIndexOf(' ');
|
var lastSpace = preText.lastIndexOf(' ');
|
||||||
@@ -150,13 +146,15 @@ module.exports = React.createClass({
|
|||||||
this.handleBackspace(e);
|
this.handleBackspace(e);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleBackspace: function(e) {
|
handleBackspace: function() {
|
||||||
var text = this.refs.message.getDOMNode().value;
|
var text = this.refs.message.getDOMNode().value;
|
||||||
if (text.indexOf("/") == 0) {
|
if (text.indexOf('/') === 0) {
|
||||||
this.refs.commands.getSuggestedCommands(text.substring(0, text.length-1));
|
this.refs.commands.getSuggestedCommands(text.substring(0, text.length - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.doProcessMentions) return;
|
if (this.doProcessMentions) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var caret = utils.getCaretPosition(this.refs.message.getDOMNode());
|
var caret = utils.getCaretPosition(this.refs.message.getDOMNode());
|
||||||
var preText = text.substring(0, caret);
|
var preText = text.substring(0, caret);
|
||||||
@@ -167,57 +165,6 @@ module.exports = React.createClass({
|
|||||||
this.doProcessMentions = true;
|
this.doProcessMentions = true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
processMentions: function() {
|
|
||||||
/* First, find all the possible mentions and add
|
|
||||||
them all to a list of mentions */
|
|
||||||
var text = utils.insertHtmlEntities(this.refs.message.getDOMNode().value);
|
|
||||||
|
|
||||||
var profileMap = UserStore.getProfilesUsernameMap();
|
|
||||||
|
|
||||||
var re1 = /@([a-z0-9_]+)( |$|\n)/gi;
|
|
||||||
|
|
||||||
var matches = text.match(re1);
|
|
||||||
|
|
||||||
if (!matches) {
|
|
||||||
this.updateMentionTab(null, []);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var mentions = [];
|
|
||||||
for (var i = 0; i < matches.length; i++) {
|
|
||||||
var m = matches[i].substring(1,matches[i].length).trim();
|
|
||||||
if ((m in profileMap && mentions.indexOf(m) === -1) || Constants.SPECIAL_MENTIONS.indexOf(m) !== -1) {
|
|
||||||
mentions.push(m);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Figure out what the user is currently typing. If it's a mention then we don't
|
|
||||||
want to add it to the mention list yet, so we remove it if
|
|
||||||
there is only one occurence of that mention so far. */
|
|
||||||
var caret = utils.getCaretPosition(this.refs.message.getDOMNode());
|
|
||||||
|
|
||||||
var text = this.props.messageText;
|
|
||||||
|
|
||||||
var preText = text.substring(0, caret);
|
|
||||||
|
|
||||||
var atIndex = preText.lastIndexOf('@');
|
|
||||||
var spaceIndex = preText.lastIndexOf(' ');
|
|
||||||
var newLineIndex = preText.lastIndexOf('\n');
|
|
||||||
|
|
||||||
var typingMention = "";
|
|
||||||
if (atIndex > spaceIndex && atIndex > newLineIndex) {
|
|
||||||
|
|
||||||
typingMention = text.substring(atIndex+1, caret);
|
|
||||||
}
|
|
||||||
|
|
||||||
var re2 = new RegExp('@' + typingMention + '( |$|\n)', 'g');
|
|
||||||
|
|
||||||
if ((text.match(re2) || []).length === 1 && mentions.indexOf(typingMention) !== -1) {
|
|
||||||
mentions.splice(mentions.indexOf(typingMention), 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.updateMentionTab(null, mentions);
|
|
||||||
},
|
|
||||||
checkForNewMention: function(text) {
|
checkForNewMention: function(text) {
|
||||||
var caret = utils.getCaretPosition(this.refs.message.getDOMNode());
|
var caret = utils.getCaretPosition(this.refs.message.getDOMNode());
|
||||||
|
|
||||||
@@ -227,7 +174,7 @@ module.exports = React.createClass({
|
|||||||
|
|
||||||
// The @ character not typed, so nothing to do.
|
// The @ character not typed, so nothing to do.
|
||||||
if (atIndex === -1) {
|
if (atIndex === -1) {
|
||||||
this.updateMentionTab('-1', null);
|
this.updateMentionTab('-1');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,13 +183,13 @@ module.exports = React.createClass({
|
|||||||
|
|
||||||
// If there is a space after the last @, nothing to do.
|
// If there is a space after the last @, nothing to do.
|
||||||
if (lastSpace > atIndex || lastCharSpace > atIndex) {
|
if (lastSpace > atIndex || lastCharSpace > atIndex) {
|
||||||
this.updateMentionTab('-1', null);
|
this.updateMentionTab('-1');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the name typed so far.
|
// Get the name typed so far.
|
||||||
var name = preText.substring(atIndex+1, preText.length).toLowerCase();
|
var name = preText.substring(atIndex + 1, preText.length).toLowerCase();
|
||||||
this.updateMentionTab(name, null);
|
this.updateMentionTab(name);
|
||||||
},
|
},
|
||||||
addMention: function(name) {
|
addMention: function(name) {
|
||||||
var caret = utils.getCaretPosition(this.refs.message.getDOMNode());
|
var caret = utils.getCaretPosition(this.refs.message.getDOMNode());
|
||||||
@@ -264,7 +211,7 @@ module.exports = React.createClass({
|
|||||||
this.addedMention = true;
|
this.addedMention = true;
|
||||||
this.doProcessMentions = true;
|
this.doProcessMentions = true;
|
||||||
|
|
||||||
this.props.onUserInput(prefix + "@" + name + " " + suffix);
|
this.props.onUserInput(prefix + '@' + name + ' ' + suffix);
|
||||||
},
|
},
|
||||||
addCommand: function(cmd) {
|
addCommand: function(cmd) {
|
||||||
var elm = this.refs.message.getDOMNode();
|
var elm = this.refs.message.getDOMNode();
|
||||||
@@ -275,22 +222,26 @@ module.exports = React.createClass({
|
|||||||
var e = this.refs.message.getDOMNode();
|
var e = this.refs.message.getDOMNode();
|
||||||
var w = this.refs.wrapper.getDOMNode();
|
var w = this.refs.wrapper.getDOMNode();
|
||||||
|
|
||||||
var lht = parseInt($(e).css('lineHeight'),10);
|
var lht = parseInt($(e).css('lineHeight'), 10);
|
||||||
var lines = e.scrollHeight / lht;
|
var lines = e.scrollHeight / lht;
|
||||||
var mod = lines < 2.5 || this.props.messageText === "" ? 30 : 15;
|
var mod = 15;
|
||||||
|
|
||||||
|
if (lines < 2.5 || this.props.messageText === '') {
|
||||||
|
mod = 30;
|
||||||
|
}
|
||||||
|
|
||||||
if (e.scrollHeight - mod < 167) {
|
if (e.scrollHeight - mod < 167) {
|
||||||
$(e).css({'height':'auto','overflow-y':'hidden'}).height(e.scrollHeight - mod);
|
$(e).css({height: 'auto', 'overflow-y': 'hidden'}).height(e.scrollHeight - mod);
|
||||||
$(w).css({'height':'auto'}).height(e.scrollHeight+2);
|
$(w).css({height: 'auto'}).height(e.scrollHeight + 2);
|
||||||
} else {
|
} else {
|
||||||
$(e).css({'height':'auto','overflow-y':'scroll'}).height(167);
|
$(e).css({height: 'auto', 'overflow-y': 'scroll'}).height(167);
|
||||||
$(w).css({'height':'auto'}).height(167);
|
$(w).css({height: 'auto'}).height(167);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleFocus: function() {
|
handleFocus: function() {
|
||||||
var elm = this.refs.message.getDOMNode();
|
var elm = this.refs.message.getDOMNode();
|
||||||
if (elm.title === elm.value) {
|
if (elm.title === elm.value) {
|
||||||
elm.value = "";
|
elm.value = '';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleBlur: function() {
|
handleBlur: function() {
|
||||||
@@ -304,9 +255,9 @@ module.exports = React.createClass({
|
|||||||
},
|
},
|
||||||
render: function() {
|
render: function() {
|
||||||
return (
|
return (
|
||||||
<div ref="wrapper" className="textarea-wrapper">
|
<div ref='wrapper' className='textarea-wrapper'>
|
||||||
<CommandList ref='commands' addCommand={this.addCommand} channelId={this.props.channelId} />
|
<CommandList ref='commands' addCommand={this.addCommand} channelId={this.props.channelId} />
|
||||||
<textarea id={this.props.id} ref="message" className={"form-control custom-textarea " + this.state.connection} spellCheck="true" autoComplete="off" autoCorrect="off" rows="1" placeholder={this.props.createMessage} value={this.props.messageText} onInput={this.handleChange} onChange={this.handleChange} onKeyPress={this.handleKeyPress} onKeyDown={this.handleKeyDown} onFocus={this.handleFocus} onBlur={this.handleBlur} onPaste={this.handlePaste} />
|
<textarea id={this.props.id} ref='message' className={'form-control custom-textarea ' + this.state.connection} spellCheck='true' autoComplete='off' autoCorrect='off' rows='1' placeholder={this.props.createMessage} value={this.props.messageText} onInput={this.handleChange} onChange={this.handleChange} onKeyPress={this.handleKeyPress} onKeyDown={this.handleKeyDown} onFocus={this.handleFocus} onBlur={this.handleBlur} onPaste={this.handlePaste} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ var EventEmitter = require('events').EventEmitter;
|
|||||||
var assign = require('object-assign');
|
var assign = require('object-assign');
|
||||||
|
|
||||||
var ChannelStore = require('../stores/channel_store.jsx');
|
var ChannelStore = require('../stores/channel_store.jsx');
|
||||||
var UserStore = require('../stores/user_store.jsx');
|
|
||||||
var BrowserStore = require('../stores/browser_store.jsx');
|
var BrowserStore = require('../stores/browser_store.jsx');
|
||||||
|
|
||||||
var Constants = require('../utils/constants.jsx');
|
var Constants = require('../utils/constants.jsx');
|
||||||
@@ -21,149 +20,148 @@ var ADD_MENTION_EVENT = 'add_mention';
|
|||||||
|
|
||||||
var PostStore = assign({}, EventEmitter.prototype, {
|
var PostStore = assign({}, EventEmitter.prototype, {
|
||||||
|
|
||||||
emitChange: function() {
|
emitChange: function emitChange() {
|
||||||
this.emit(CHANGE_EVENT);
|
this.emit(CHANGE_EVENT);
|
||||||
},
|
},
|
||||||
|
|
||||||
addChangeListener: function(callback) {
|
addChangeListener: function addChangeListener(callback) {
|
||||||
this.on(CHANGE_EVENT, callback);
|
this.on(CHANGE_EVENT, callback);
|
||||||
},
|
},
|
||||||
|
|
||||||
removeChangeListener: function(callback) {
|
removeChangeListener: function removeChangeListener(callback) {
|
||||||
this.removeListener(CHANGE_EVENT, callback);
|
this.removeListener(CHANGE_EVENT, callback);
|
||||||
},
|
},
|
||||||
|
|
||||||
emitSearchChange: function() {
|
emitSearchChange: function emitSearchChange() {
|
||||||
this.emit(SEARCH_CHANGE_EVENT);
|
this.emit(SEARCH_CHANGE_EVENT);
|
||||||
},
|
},
|
||||||
|
|
||||||
addSearchChangeListener: function(callback) {
|
addSearchChangeListener: function addSearchChangeListener(callback) {
|
||||||
this.on(SEARCH_CHANGE_EVENT, callback);
|
this.on(SEARCH_CHANGE_EVENT, callback);
|
||||||
},
|
},
|
||||||
|
|
||||||
removeSearchChangeListener: function(callback) {
|
removeSearchChangeListener: function removeSearchChangeListener(callback) {
|
||||||
this.removeListener(SEARCH_CHANGE_EVENT, callback);
|
this.removeListener(SEARCH_CHANGE_EVENT, callback);
|
||||||
},
|
},
|
||||||
|
|
||||||
emitSearchTermChange: function(doSearch, isMentionSearch) {
|
emitSearchTermChange: function emitSearchTermChange(doSearch, isMentionSearch) {
|
||||||
this.emit(SEARCH_TERM_CHANGE_EVENT, doSearch, isMentionSearch);
|
this.emit(SEARCH_TERM_CHANGE_EVENT, doSearch, isMentionSearch);
|
||||||
},
|
},
|
||||||
|
|
||||||
addSearchTermChangeListener: function(callback) {
|
addSearchTermChangeListener: function addSearchTermChangeListener(callback) {
|
||||||
this.on(SEARCH_TERM_CHANGE_EVENT, callback);
|
this.on(SEARCH_TERM_CHANGE_EVENT, callback);
|
||||||
},
|
},
|
||||||
|
|
||||||
removeSearchTermChangeListener: function(callback) {
|
removeSearchTermChangeListener: function removeSearchTermChangeListener(callback) {
|
||||||
this.removeListener(SEARCH_TERM_CHANGE_EVENT, callback);
|
this.removeListener(SEARCH_TERM_CHANGE_EVENT, callback);
|
||||||
},
|
},
|
||||||
|
|
||||||
emitSelectedPostChange: function(from_search) {
|
emitSelectedPostChange: function emitSelectedPostChange(fromSearch) {
|
||||||
this.emit(SELECTED_POST_CHANGE_EVENT, from_search);
|
this.emit(SELECTED_POST_CHANGE_EVENT, fromSearch);
|
||||||
},
|
},
|
||||||
|
|
||||||
addSelectedPostChangeListener: function(callback) {
|
addSelectedPostChangeListener: function addSelectedPostChangeListener(callback) {
|
||||||
this.on(SELECTED_POST_CHANGE_EVENT, callback);
|
this.on(SELECTED_POST_CHANGE_EVENT, callback);
|
||||||
},
|
},
|
||||||
|
|
||||||
removeSelectedPostChangeListener: function(callback) {
|
removeSelectedPostChangeListener: function removeSelectedPostChangeListener(callback) {
|
||||||
this.removeListener(SELECTED_POST_CHANGE_EVENT, callback);
|
this.removeListener(SELECTED_POST_CHANGE_EVENT, callback);
|
||||||
},
|
},
|
||||||
|
|
||||||
emitMentionDataChange: function(id, mentionText, excludeList) {
|
emitMentionDataChange: function emitMentionDataChange(id, mentionText) {
|
||||||
this.emit(MENTION_DATA_CHANGE_EVENT, id, mentionText, excludeList);
|
this.emit(MENTION_DATA_CHANGE_EVENT, id, mentionText);
|
||||||
},
|
},
|
||||||
|
|
||||||
addMentionDataChangeListener: function(callback) {
|
addMentionDataChangeListener: function addMentionDataChangeListener(callback) {
|
||||||
this.on(MENTION_DATA_CHANGE_EVENT, callback);
|
this.on(MENTION_DATA_CHANGE_EVENT, callback);
|
||||||
},
|
},
|
||||||
|
|
||||||
removeMentionDataChangeListener: function(callback) {
|
removeMentionDataChangeListener: function removeMentionDataChangeListener(callback) {
|
||||||
this.removeListener(MENTION_DATA_CHANGE_EVENT, callback);
|
this.removeListener(MENTION_DATA_CHANGE_EVENT, callback);
|
||||||
},
|
},
|
||||||
|
|
||||||
emitAddMention: function(id, username) {
|
emitAddMention: function emitAddMention(id, username) {
|
||||||
this.emit(ADD_MENTION_EVENT, id, username);
|
this.emit(ADD_MENTION_EVENT, id, username);
|
||||||
},
|
},
|
||||||
|
|
||||||
addAddMentionListener: function(callback) {
|
addAddMentionListener: function addAddMentionListener(callback) {
|
||||||
this.on(ADD_MENTION_EVENT, callback);
|
this.on(ADD_MENTION_EVENT, callback);
|
||||||
},
|
},
|
||||||
|
|
||||||
removeAddMentionListener: function(callback) {
|
removeAddMentionListener: function removeAddMentionListener(callback) {
|
||||||
this.removeListener(ADD_MENTION_EVENT, callback);
|
this.removeListener(ADD_MENTION_EVENT, callback);
|
||||||
},
|
},
|
||||||
|
|
||||||
getCurrentPosts: function() {
|
getCurrentPosts: function getCurrentPosts() {
|
||||||
var currentId = ChannelStore.getCurrentId();
|
var currentId = ChannelStore.getCurrentId();
|
||||||
|
|
||||||
if (currentId != null)
|
if (currentId != null) {
|
||||||
return this.getPosts(currentId);
|
return this.getPosts(currentId);
|
||||||
else
|
}
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
storePosts: function(channelId, posts) {
|
storePosts: function storePosts(channelId, posts) {
|
||||||
this._storePosts(channelId, posts);
|
this.pStorePosts(channelId, posts);
|
||||||
this.emitChange();
|
this.emitChange();
|
||||||
},
|
},
|
||||||
_storePosts: function(channelId, posts) {
|
pStorePosts: function pStorePosts(channelId, posts) {
|
||||||
BrowserStore.setItem("posts_" + channelId, posts);
|
BrowserStore.setItem('posts_' + channelId, posts);
|
||||||
},
|
},
|
||||||
getPosts: function(channelId) {
|
getPosts: function getPosts(channelId) {
|
||||||
return BrowserStore.getItem("posts_" + channelId);
|
return BrowserStore.getItem('posts_' + channelId);
|
||||||
},
|
},
|
||||||
storeSearchResults: function(results, is_mention_search) {
|
storeSearchResults: function storeSearchResults(results, isMentionSearch) {
|
||||||
BrowserStore.setItem("search_results", results);
|
BrowserStore.setItem('search_results', results);
|
||||||
is_mention_search = is_mention_search ? true : false; // force to bool
|
BrowserStore.setItem('is_mention_search', Boolean(isMentionSearch));
|
||||||
BrowserStore.setItem("is_mention_search", is_mention_search);
|
|
||||||
},
|
},
|
||||||
getSearchResults: function() {
|
getSearchResults: function getSearchResults() {
|
||||||
return BrowserStore.getItem("search_results");
|
return BrowserStore.getItem('search_results');
|
||||||
},
|
},
|
||||||
getIsMentionSearch: function() {
|
getIsMentionSearch: function getIsMentionSearch() {
|
||||||
return BrowserStore.getItem("is_mention_search");
|
return BrowserStore.getItem('is_mention_search');
|
||||||
},
|
},
|
||||||
storeSelectedPost: function(post_list) {
|
storeSelectedPost: function storeSelectedPost(postList) {
|
||||||
BrowserStore.setItem("select_post", post_list);
|
BrowserStore.setItem('select_post', postList);
|
||||||
},
|
},
|
||||||
getSelectedPost: function() {
|
getSelectedPost: function getSelectedPost() {
|
||||||
return BrowserStore.getItem("select_post");
|
return BrowserStore.getItem('select_post');
|
||||||
},
|
},
|
||||||
storeSearchTerm: function(term) {
|
storeSearchTerm: function storeSearchTerm(term) {
|
||||||
BrowserStore.setItem("search_term", term);
|
BrowserStore.setItem('search_term', term);
|
||||||
},
|
},
|
||||||
getSearchTerm: function() {
|
getSearchTerm: function getSearchTerm() {
|
||||||
return BrowserStore.getItem("search_term");
|
return BrowserStore.getItem('search_term');
|
||||||
},
|
},
|
||||||
storeCurrentDraft: function(draft) {
|
storeCurrentDraft: function storeCurrentDraft(draft) {
|
||||||
var channel_id = ChannelStore.getCurrentId();
|
var channelId = ChannelStore.getCurrentId();
|
||||||
BrowserStore.setItem("draft_" + channel_id, draft);
|
BrowserStore.setItem('draft_' + channelId, draft);
|
||||||
},
|
},
|
||||||
getCurrentDraft: function() {
|
getCurrentDraft: function getCurrentDraft() {
|
||||||
var channel_id = ChannelStore.getCurrentId();
|
var channelId = ChannelStore.getCurrentId();
|
||||||
return BrowserStore.getItem("draft_" + channel_id);
|
return BrowserStore.getItem('draft_' + channelId);
|
||||||
},
|
},
|
||||||
storeDraft: function(channel_id, draft) {
|
storeDraft: function storeDraft(channelId, draft) {
|
||||||
BrowserStore.setItem("draft_" + channel_id, draft);
|
BrowserStore.setItem('draft_' + channelId, draft);
|
||||||
},
|
},
|
||||||
getDraft: function(channel_id) {
|
getDraft: function getDraft(channelId) {
|
||||||
return BrowserStore.getItem("draft_" + channel_id);
|
return BrowserStore.getItem('draft_' + channelId);
|
||||||
},
|
},
|
||||||
storeCommentDraft: function(parent_post_id, draft) {
|
storeCommentDraft: function storeCommentDraft(parentPostId, draft) {
|
||||||
BrowserStore.setItem("comment_draft_" + parent_post_id, draft);
|
BrowserStore.setItem('comment_draft_' + parentPostId, draft);
|
||||||
},
|
},
|
||||||
getCommentDraft: function(parent_post_id) {
|
getCommentDraft: function getCommentDraft(parentPostId) {
|
||||||
return BrowserStore.getItem("comment_draft_" + parent_post_id);
|
return BrowserStore.getItem('comment_draft_' + parentPostId);
|
||||||
},
|
},
|
||||||
clearDraftUploads: function() {
|
clearDraftUploads: function clearDraftUploads() {
|
||||||
BrowserStore.actionOnItemsWithPrefix("draft_", function (key, value) {
|
BrowserStore.actionOnItemsWithPrefix('draft_', function clearUploads(key, value) {
|
||||||
if (value) {
|
if (value) {
|
||||||
value.uploadsInProgress = 0;
|
value.uploadsInProgress = 0;
|
||||||
BrowserStore.setItem(key, value);
|
BrowserStore.setItem(key, value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
clearCommentDraftUploads: function() {
|
clearCommentDraftUploads: function clearCommentDraftUploads() {
|
||||||
BrowserStore.actionOnItemsWithPrefix("comment_draft_", function (key, value) {
|
BrowserStore.actionOnItemsWithPrefix('comment_draft_', function clearUploads(key, value) {
|
||||||
if (value) {
|
if (value) {
|
||||||
value.uploadsInProgress = 0;
|
value.uploadsInProgress = 0;
|
||||||
BrowserStore.setItem(key, value);
|
BrowserStore.setItem(key, value);
|
||||||
@@ -172,12 +170,12 @@ var PostStore = assign({}, EventEmitter.prototype, {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
PostStore.dispatchToken = AppDispatcher.register(function(payload) {
|
PostStore.dispatchToken = AppDispatcher.register(function registry(payload) {
|
||||||
var action = payload.action;
|
var action = payload.action;
|
||||||
|
|
||||||
switch(action.type) {
|
switch (action.type) {
|
||||||
case ActionTypes.RECIEVED_POSTS:
|
case ActionTypes.RECIEVED_POSTS:
|
||||||
PostStore._storePosts(action.id, action.post_list);
|
PostStore.pStorePosts(action.id, action.post_list);
|
||||||
PostStore.emitChange();
|
PostStore.emitChange();
|
||||||
break;
|
break;
|
||||||
case ActionTypes.RECIEVED_SEARCH:
|
case ActionTypes.RECIEVED_SEARCH:
|
||||||
@@ -193,7 +191,7 @@ PostStore.dispatchToken = AppDispatcher.register(function(payload) {
|
|||||||
PostStore.emitSelectedPostChange(action.from_search);
|
PostStore.emitSelectedPostChange(action.from_search);
|
||||||
break;
|
break;
|
||||||
case ActionTypes.RECIEVED_MENTION_DATA:
|
case ActionTypes.RECIEVED_MENTION_DATA:
|
||||||
PostStore.emitMentionDataChange(action.id, action.mention_text, action.exclude_list);
|
PostStore.emitMentionDataChange(action.id, action.mention_text);
|
||||||
break;
|
break;
|
||||||
case ActionTypes.RECIEVED_ADD_MENTION:
|
case ActionTypes.RECIEVED_ADD_MENTION:
|
||||||
PostStore.emitAddMention(action.id, action.username);
|
PostStore.emitAddMention(action.id, action.username);
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user