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

Improving selectors of Textbox component #9831

Merged
merged 5 commits into from
Feb 17, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
review changes
  • Loading branch information
M-ZubairAhmed committed Feb 17, 2022
commit 7a32147399ad8a4bdd3dccf79341822c755c9e6c
8 changes: 4 additions & 4 deletions components/__snapshots__/textbox.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ exports[`components/TextBox should match snapshot with additional, optional prop
},
],
"autocompleteUsersInChannel": [Function],
"currentChannelId": "channelId",
"channelId": "channelId",
"currentUserId": "currentUserId",
"data": null,
"disableDispatches": false,
Expand Down Expand Up @@ -148,7 +148,7 @@ exports[`components/TextBox should match snapshot with required props 1`] = `
},
],
"autocompleteUsersInChannel": [Function],
"currentChannelId": "channelId",
"channelId": "channelId",
"currentUserId": "currentUserId",
"data": null,
"disableDispatches": false,
Expand Down Expand Up @@ -236,7 +236,7 @@ exports[`components/TextBox should throw error when new property is too long 1`]
},
],
"autocompleteUsersInChannel": [Function],
"currentChannelId": "channelId",
"channelId": "channelId",
"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`] = `
},
],
"autocompleteUsersInChannel": [Function],
"currentChannelId": "channelId",
"channelId": "channelId",
"currentUserId": "currentUserId",
"data": null,
"disableDispatches": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ export default class AtMentionProvider extends Provider {

// setProps gives the provider additional context for matching pretexts. Ideally this would
// just be something akin to a connected component with access to the store itself.
setProps({currentUserId, currentChannelId, autocompleteUsersInChannel, useChannelMentions, autocompleteGroups, searchAssociatedGroupsForReference, priorityProfiles}) {
setProps({currentUserId, channelId, autocompleteUsersInChannel, useChannelMentions, autocompleteGroups, searchAssociatedGroupsForReference, priorityProfiles}) {
this.currentUserId = currentUserId;
this.currentChannelId = currentChannelId;
this.channelId = channelId;
this.autocompleteUsersInChannel = autocompleteUsersInChannel;
this.useChannelMentions = useChannelMentions;
this.autocompleteGroups = autocompleteGroups;
Expand Down Expand Up @@ -125,7 +125,7 @@ export default class AtMentionProvider extends Provider {
getProfilesWithLastViewAtInChannel() {
const state = store.getState();

const profilesInChannel = this.getProfilesInChannel(state, this.currentChannelId, profilesInChannelOptions);
const profilesInChannel = this.getProfilesInChannel(state, this.channelId, profilesInChannelOptions);
const profilesWithLastViewAtInChannel = this.addLastViewAtToProfiles(state, profilesInChannel);
hmhealey marked this conversation as resolved.
Show resolved Hide resolved

return profilesWithLastViewAtInChannel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ describe('components/suggestion/at_mention_provider/AtMentionProvider', () => {

const baseParams = {
currentUserId: 'userid1',
currentTeamId: 'teamid1',
currentChannelId: 'channelid1',
channelId: 'channelid1',
autocompleteUsersInChannel: jest.fn().mockResolvedValue(false),
autocompleteGroups: [groupid1, groupid2, groupid3],
useChannelMentions: true,
Expand Down
4 changes: 2 additions & 2 deletions components/textbox/textbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export default class Textbox extends React.PureComponent<Props> {
this.suggestionProviders.push(
new AtMentionProvider({
currentUserId: this.props.currentUserId,
currentChannelId: this.props.channelId,
channelId: this.props.channelId,
autocompleteUsersInChannel: (prefix: string) => this.props.actions.autocompleteUsersInChannel(prefix, this.props.channelId),
useChannelMentions: this.props.useChannelMentions,
autocompleteGroups: this.props.autocompleteGroups,
Expand Down Expand Up @@ -134,7 +134,7 @@ export default class Textbox extends React.PureComponent<Props> {
if (provider instanceof AtMentionProvider) {
provider.setProps({
currentUserId: this.props.currentUserId,
currentChannelId: this.props.channelId,
channelId: this.props.channelId,
autocompleteUsersInChannel: (prefix: string) => this.props.actions.autocompleteUsersInChannel(prefix, this.props.channelId),
useChannelMentions: this.props.useChannelMentions,
autocompleteGroups: this.props.autocompleteGroups,
Expand Down