forked from Ivasoft/mattermost-mobile
* update eslint's `comma-dangle` rule to `always-multiline` * add check and fix scripts to package.json * Invoke `yarn fix` to adopt the updated eslint rules. No other changes are included.
60 lines
1.8 KiB
JavaScript
60 lines
1.8 KiB
JavaScript
// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
|
|
// See License.txt for license information.
|
|
|
|
import {bindActionCreators} from 'redux';
|
|
import {connect} from 'react-redux';
|
|
|
|
import {autocompleteUsers} from 'mattermost-redux/actions/users';
|
|
import {getCurrentChannelId, getDefaultChannel} from 'mattermost-redux/selectors/entities/channels';
|
|
import {getCurrentTeamId} from 'mattermost-redux/selectors/entities/teams';
|
|
|
|
import {
|
|
filterMembersInChannel,
|
|
filterMembersNotInChannel,
|
|
filterMembersInCurrentTeam,
|
|
getMatchTermForAtMention,
|
|
} from 'app/selectors/autocomplete';
|
|
import {getTheme} from 'mattermost-redux/selectors/entities/preferences';
|
|
|
|
import AtMention from './at_mention';
|
|
|
|
function mapStateToProps(state, ownProps) {
|
|
const {cursorPosition, isSearch} = ownProps;
|
|
const currentChannelId = getCurrentChannelId(state);
|
|
|
|
const value = ownProps.value.substring(0, cursorPosition);
|
|
const matchTerm = getMatchTermForAtMention(value, isSearch);
|
|
|
|
let teamMembers;
|
|
let inChannel;
|
|
let outChannel;
|
|
if (isSearch) {
|
|
teamMembers = filterMembersInCurrentTeam(state, matchTerm);
|
|
} else {
|
|
inChannel = filterMembersInChannel(state, matchTerm);
|
|
outChannel = filterMembersNotInChannel(state, matchTerm);
|
|
}
|
|
|
|
return {
|
|
currentChannelId,
|
|
currentTeamId: getCurrentTeamId(state),
|
|
defaultChannel: getDefaultChannel(state),
|
|
matchTerm,
|
|
teamMembers,
|
|
inChannel,
|
|
outChannel,
|
|
requestStatus: state.requests.users.autocompleteUsers.status,
|
|
theme: getTheme(state),
|
|
};
|
|
}
|
|
|
|
function mapDispatchToProps(dispatch) {
|
|
return {
|
|
actions: bindActionCreators({
|
|
autocompleteUsers,
|
|
}, dispatch),
|
|
};
|
|
}
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(AtMention);
|