forked from Ivasoft/mattermost-mobile
fix slash command autocomplete suggestion key issue
This commit is contained in:
@@ -31,7 +31,18 @@ export type Props = {
|
||||
listStyle: StyleProp<ViewStyle>;
|
||||
};
|
||||
|
||||
const keyExtractor = (item: ExtendedAutocompleteSuggestion): string => item.Suggestion + item.type + item.item;
|
||||
const keyExtractor = (item: ExtendedAutocompleteSuggestion): string => {
|
||||
switch (item.type) {
|
||||
case COMMAND_SUGGESTION_USER:
|
||||
const user = item.item as UserProfile;
|
||||
return user.id;
|
||||
case COMMAND_SUGGESTION_CHANNEL:
|
||||
const channel = item.item as Channel;
|
||||
return channel.id;
|
||||
default:
|
||||
return item.Suggestion;
|
||||
}
|
||||
}
|
||||
|
||||
const emptySuggestonList: AutocompleteSuggestion[] = [];
|
||||
|
||||
@@ -97,23 +108,27 @@ const AppSlashSuggestion = ({
|
||||
const renderItem = useCallback(({item}: {item: ExtendedAutocompleteSuggestion}) => {
|
||||
switch (item.type) {
|
||||
case COMMAND_SUGGESTION_USER:
|
||||
if (!item.item) {
|
||||
const user = item.item as UserProfile | undefined;
|
||||
if (!user) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<AtMentionItem
|
||||
user={item.item as UserProfile | UserModel}
|
||||
user={user}
|
||||
onPress={completeIgnoringSuggestion(item.Complete)}
|
||||
testID='autocomplete.slash_suggestion.at_mention_item'
|
||||
/>
|
||||
);
|
||||
case COMMAND_SUGGESTION_CHANNEL:
|
||||
if (!item.item) {
|
||||
const channel = item.item as Channel | undefined;
|
||||
if (!channel) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<ChannelMentionItem
|
||||
channel={item.item as Channel | ChannelModel}
|
||||
channel={channel}
|
||||
onPress={completeIgnoringSuggestion(item.Complete)}
|
||||
testID='autocomplete.slash_suggestion.channel_mention_item'
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user