Skip to content

Commit

Permalink
Filter out self from create chat search results on mobile (#3462)
Browse files Browse the repository at this point in the history
  • Loading branch information
dharit-tan authored May 30, 2023
1 parent a42e359 commit 593914c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/mobile/src/screens/chat-screen/ChatUserListItem.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useCallback } from 'react'

import { chatActions, chatSelectors } from '@audius/common'
import { chatActions, accountSelectors, chatSelectors } from '@audius/common'
import type { User } from '@audius/common'
import { useSelector } from 'audius-client/src/common/hooks/useSelector'
import { Text, View, TouchableOpacity } from 'react-native'
Expand All @@ -14,6 +14,7 @@ import { useThemeColors } from 'app/utils/theme'

const { createChat } = chatActions
const { getCanCreateChat } = chatSelectors
const { getUserId } = accountSelectors

const messages = {
followsYou: 'Follows You',
Expand Down Expand Up @@ -107,6 +108,7 @@ export const ChatUserListItem = ({ user }: ChatUserListItemProps) => {
const styles = useStyles()
const palette = useThemeColors()
const dispatch = useDispatch()
const currentUserId = useSelector(getUserId)
const { canCreateChat } = useSelector((state) =>
getCanCreateChat(state, { userId: user.user_id })
)
Expand All @@ -118,6 +120,10 @@ export const ChatUserListItem = ({ user }: ChatUserListItemProps) => {
[dispatch]
)

if (currentUserId === user.user_id) {
return null
}

return (
<TouchableOpacity
onPress={() => handlePress(user)}
Expand Down

0 comments on commit 593914c

Please sign in to comment.