Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

MM-13209: use textbox channel from context #2108

Merged
merged 5 commits into from
Dec 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions actions/views/channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// See LICENSE.txt for license information.

import {leaveChannel as leaveChannelRedux, joinChannel, unfavoriteChannel} from 'mattermost-redux/actions/channels';
import {getChannel, getChannelByName, getCurrentChannelId} from 'mattermost-redux/selectors/entities/channels';
import {getChannel, getChannelByName} from 'mattermost-redux/selectors/entities/channels';
import {getCurrentRelativeTeamUrl, getCurrentTeamId} from 'mattermost-redux/selectors/entities/teams';
import {getCurrentUserId, getUserByUsername} from 'mattermost-redux/selectors/entities/users';
import {getMyPreferences} from 'mattermost-redux/selectors/entities/preferences';
Expand Down Expand Up @@ -102,13 +102,12 @@ export function leaveChannel(channelId) {
};
}

export function autocompleteUsersInChannel(prefix) {
export function autocompleteUsersInChannel(prefix, channelId) {
return async (dispatch, getState) => {
const state = getState();
const currentTeamId = getCurrentTeamId(state);
const currentChannelId = getCurrentChannelId(state);

return dispatch(autocompleteUsers(prefix, currentTeamId, currentChannelId));
return dispatch(autocompleteUsers(prefix, currentTeamId, channelId));
};
}

6 changes: 3 additions & 3 deletions components/__snapshots__/textbox.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ exports[`components/TextBox should match snapshot with required props 1`] = `
providers={
Array [
AtMentionProvider {
"autocompleteUsersInChannel": [MockFunction],
"autocompleteUsersInChannel": [Function],
"currentUserId": "currentUserId",
"data": null,
"disableDispatches": false,
Expand Down Expand Up @@ -174,7 +174,7 @@ exports[`components/TextBox should throw error when new property is too long 1`]
providers={
Array [
AtMentionProvider {
"autocompleteUsersInChannel": [MockFunction],
"autocompleteUsersInChannel": [Function],
"currentUserId": "currentUserId",
"data": null,
"disableDispatches": false,
Expand Down Expand Up @@ -324,7 +324,7 @@ exports[`components/TextBox should throw error when value is too long 1`] = `
providers={
Array [
AtMentionProvider {
"autocompleteUsersInChannel": [MockFunction],
"autocompleteUsersInChannel": [Function],
"currentUserId": "currentUserId",
"data": null,
"disableDispatches": false,
Expand Down
19 changes: 12 additions & 7 deletions components/textbox/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,27 @@
import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';

import {getCurrentUserId, getProfilesInCurrentChannel, getProfilesNotInCurrentChannel} from 'mattermost-redux/selectors/entities/users';
import {getCurrentUserId, makeGetProfilesInChannel, makeGetProfilesNotInChannel} from 'mattermost-redux/selectors/entities/users';

import {autocompleteUsersInChannel} from 'actions/views/channel';

import Textbox from './textbox.jsx';

const mapStateToProps = (state) => ({
currentUserId: getCurrentUserId(state),
profilesInChannel: getProfilesInCurrentChannel(state),
profilesNotInChannel: getProfilesNotInCurrentChannel(state),
});
const makeMapStateToProps = () => {
const getProfilesInChannel = makeGetProfilesInChannel();
const getProfilesNotInChannel = makeGetProfilesNotInChannel();

return (state, ownProps) => ({
currentUserId: getCurrentUserId(state),
profilesInChannel: getProfilesInChannel(state, ownProps.channelId, true),
profilesNotInChannel: getProfilesNotInChannel(state, ownProps.channelId, true),
});
};

const mapDispatchToProps = (dispatch) => ({
actions: bindActionCreators({
autocompleteUsersInChannel,
}, dispatch),
});

export default connect(mapStateToProps, mapDispatchToProps, null, {withRef: true})(Textbox);
export default connect(makeMapStateToProps, mapDispatchToProps, null, {withRef: true})(Textbox);
4 changes: 2 additions & 2 deletions components/textbox/textbox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default class Textbox extends React.Component {
currentUserId: this.props.currentUserId,
profilesInChannel: this.props.profilesInChannel,
profilesNotInChannel: this.props.profilesNotInChannel,
autocompleteUsersInChannel: this.props.actions.autocompleteUsersInChannel,
autocompleteUsersInChannel: (prefix) => this.props.actions.autocompleteUsersInChannel(prefix, props.channelId),
}),
new ChannelMentionProvider(),
new EmoticonProvider(),
Expand Down Expand Up @@ -180,7 +180,7 @@ export default class Textbox extends React.Component {
currentUserId: nextProps.currentUserId,
profilesInChannel: nextProps.profilesInChannel,
profilesNotInChannel: nextProps.profilesNotInChannel,
autocompleteUsersInChannel: nextProps.actions.autocompleteUsersInChannel,
autocompleteUsersInChannel: (prefix) => nextProps.actions.autocompleteUsersInChannel(prefix, nextProps.channelId),
});
}
}
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"localforage": "1.7.2",
"localforage-observable": "1.4.0",
"marked": "github:mattermost/marked#ed33baecd7d7fa97d479ba22dde9d226b083d67d",
"mattermost-redux": "github:mattermost/mattermost-redux#212101f413f0c8288f4250a74b60a8c8c58418f7",
"mattermost-redux": "github:mattermost/mattermost-redux#632cda350e295aa0d7af07905c879b5014ca9456",
"moment-timezone": "0.5.21",
"pdfjs-dist": "2.0.489",
"perfect-scrollbar": "0.8.1",
Expand Down