Options
All
  • Public
  • Public/Protected
  • All
Menu

Service hooks interface for injecting business data into ChatUI

description

Provides callback functions to fetch user profiles, group profiles, system profiles, and group members from your backend

Hierarchy

  • ServiceHooks

Index

Methods

  • Fetch user profiles by user IDs in batch

    example
    reqUserProfiles: async (userIds) => {
    const users = await fetchUsersFromBackend(userIds);
    return users.map(user => ({
    userId: user.id,
    name: user.displayName,
    portraitUri: user.avatarUrl
    }));
    }

    Parameters

    • userIds: string[]

      Array of user IDs

    Returns Promise<ChatUIUserProfile[]>

    Promise resolving to array of user profiles

  • reqGroupProfiles(groupIds: string[]): Promise<GroupProfile[]>
  • Fetch group profiles by group IDs in batch

    example
    reqGroupProfiles: async (groupIds) => {
    const groups = await fetchGroupsFromBackend(groupIds);
    return groups.map(group => ({
    groupId: group.id,
    name: group.name,
    portraitUri: group.avatarUrl,
    memberCount: group.memberCount
    }));
    }

    Parameters

    • groupIds: string[]

      Array of group IDs

    Returns Promise<GroupProfile[]>

    Promise resolving to array of group profiles

  • Fetch system channel profiles in batch

    description

    Called when channel list contains ChannelType.SYSTEM type channels

    example
    reqSystemProfiles: async (targetIds) => {
    const systems = await fetchSystemChannelsFromBackend(targetIds);
    return systems.map(sys => ({
    targetId: sys.id,
    name: sys.name,
    portraitUri: sys.iconUrl
    }));
    }

    Parameters

    • targetIds: string[]

      Array of system channel IDs

    Returns Promise<ChatUISystemProfile[]>

    Promise resolving to array of system profiles

  • Fetch group member information

    example
    reqGroupMembers: async (groupId) => {
    const members = await fetchGroupMembersFromBackend(groupId);
    return members.map(member => ({
    userId: member.userId,
    nickname: member.nickname
    }));
    }

    Parameters

    • groupId: string

      Group ID

    Returns Promise<GroupMemberProfile[]>

    Promise resolving to array of group members

  • [Optional] Define default user profile to replace SDK's default initial data

    description

    Used when user profile is not yet loaded, provides placeholder data like avatar and name

    example
    getDefaultUserProfile: (userId) => ({
    userId,
    name: `User ${userId.substring(0, 8)}`,
    portraitUri: 'https://example.com/default-avatar.png'
    })

    Parameters

    • userId: string

      User ID

    Returns ChatUIUserProfile

    Default user profile

  • [Optional] Define default group profile to replace SDK's default data

    description

    Used when group profile is not yet loaded, provides placeholder data like avatar and name

    example
    getDefaultGroupProfile: (groupId) => ({
    groupId,
    name: `Group ${groupId.substring(0, 8)}`,
    avatarUrl: 'https://example.com/default-group.png',
    memberCount: 0
    })

    Parameters

    • groupId: string

      Group ID

    Returns GroupProfile

    Default group profile

  • [Optional] Define default system channel profile to replace SDK's default data

    description

    Used when system profile is not yet loaded, provides placeholder data like icon and name

    example
    getDefaultSystemProfile: (systemId) => ({
    targetId: systemId,
    name: `System ${systemId}`,
    avatarUrl: 'https://example.com/default-system.png'
    })

    Parameters

    • systemId: string

      System channel ID

    Returns ChatUISystemProfile

    Default system profile