Error searching members

Hi, I’m using this function to search members based on the display name

ChannelRepository.Membership.searchMembers(
        {
          channelId: Config.AMITYCO_COMMUNITY_CHANNEL_ID,
          search: userHint,
          roles: ['member'],
          limit: 10,
        },
        () => ...
)

When i run it without the search prop i get results, but when adding a hint it return empty not matter the string.

I’m also getting this warning but I’m following the documentation described here

 `search` param will be deprecated in the next major release. If you want to search channel members by displayName, Please use `searchMembers()` instead.

@Referi Let me pass this to check with my team, and I’ll get back to you.

@Referi Regarding your issue, we recommend checking this document: Search Members - Amity Docs for more information on searching for channel members in the Amity SDK.

Hi, as you can see in the code snippet I’m following the documentation and i having 2 issues:

  • I’m getting the drepecation warning
  • I’m getting an empty array when trying to filter by display name

Hello, are you still encountering the warning even after changing the function to searchMembers()?

Sample code:

import { ChannelRepository } from '@amityco/ts-sdk';
import { FC, useEffect, useState } from 'react';

const SearchMembers: FC<{ channelId: string; search: string }> = ({ channelId, search }) => {
  const [data, setChannelMembers] = useState<Amity.LiveCollection<Amity.Membership<'channel'>>>();
  const { data: channelMembers = [], onNextPage, hasNextPage, loading, error } = data ?? {};

  useEffect(
    () => ChannelRepository.Membership.searchMembers({ channelId, search }, setChannelMembers),
    [channelId, search],
  );

  return null;
};

If this still doesn’t solve, may I know your current TS SDK version as well, please?

Hi, Yes, I’m getting the same behaviour with searchMembers. My TS version is 6.16.0

@Referi I would like to confirm with you whether you have searched with more than 3 characters.

Hi, yes, I’m searching with more than 3 characters. I event tried with the exact name that i see on amity dashboard and didnt work

Thank you for your confirmation, we will pass to the team to check.

Hi, any updates on this?

Hello @Referi, please ensure that your ts sdk version is up-to-date and refer to the code provided from our team below:

const searchMemberChannel = () => {
    ChannelRepository.Membership.searchMembers({ channelId: "65e576694dc3bd17ca7df04d", search: "admin" },

      (value) => {
        console.log('value: ', value);

      })
  }

Hi,
I tested with version 6.18.0 and it is searching just the channel-moderators, I tested with admin and it returned the user but is not returning any other member. When changing the role of the members to channel-moderator and trying again it worked.

Hello, could you kindly provide clarification on what you mean by “it returned the user but is not returning any other member” - which user does it returned?

hi, it returned the admin user

Hello @Referi, our search feature only supports displaying results based on display name or user ID, not the user’s role. Therefore, if you search for ‘admin’ and the result returns a user with the display name or user ID ‘admin’, this is the expected behavior.

I understand, the problem I’m seeing is the feature is searching just among the channel-moderadors it is not searching among all the users.

In conclusion: the feature is not searching when i try with different display names than admin

Noted. Could you please help share the channelID where you tried to search for the member?

sure, this one: 65aec61fcb7645d0cb8eda96

@Referi I’ll pass this information to the relevant team and keep you updated.

Hello @Referi may I have your current updated code, please?