You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tailchat/client/shared/redux/hooks/useDMConverseName.ts

18 lines
548 B
TypeScript

import { getDMConverseName } from '../../helper/converse-helper';
import { isValidStr, useAsync } from '../../index';
import type { ChatConverseState } from '../slices/chat';
import { useUserId } from './useUserInfo';
export function useDMConverseName(converse: ChatConverseState) {
const userId = useUserId();
const { value: name = '' } = useAsync(async () => {
if (!isValidStr(userId)) {
return '';
}
return getDMConverseName(userId, converse);
}, [userId, converse.name, converse.members.join(',')]);
return name;
}