Refresh comments threads and count on new comment (#276)

* Refresh comments threads and count on new comment

* Fix tests
This commit is contained in:
Charles Bochet
2023-06-12 19:32:18 +02:00
committed by GitHub
parent 3341539eb2
commit 16e1b862d9
17 changed files with 74 additions and 181 deletions

View File

@ -1,6 +1,5 @@
import { CellCommentChip } from '@/comments/components/comments/CellCommentChip';
import { useOpenCommentRightDrawer } from '@/comments/hooks/useOpenCommentRightDrawer';
import { useCompanyCommentsCountQuery } from '@/comments/services';
import EditableChip from '@/ui/components/editable-cell/types/EditableChip';
import { getLogoUrlFromDomainName } from '@/utils/utils';
import { CommentableType } from '~/generated/graphql';
@ -29,8 +28,6 @@ export function CompanyEditableNameChipCell({ company }: OwnProps) {
]);
}
const commentCount = useCompanyCommentsCountQuery(company.id);
return (
<EditableChip
value={company.name || ''}
@ -45,7 +42,7 @@ export function CompanyEditableNameChipCell({ company }: OwnProps) {
ChipComponent={CompanyChip}
rightEndContents={[
<CellCommentChip
count={commentCount.data ?? 0}
count={company._commentCount ?? 0}
onClick={handleCommentClick}
/>,
]}

View File

@ -17,6 +17,7 @@ describe('Company mappers', () => {
createdAt: now.toUTCString(),
employees: 10,
address: '1 Infinite Loop, 95014 Cupertino, California, USA',
_commentCount: 1,
accountOwner: {
id: '7af20dea-0412-4c4c-8b13-d6f0e6e09e87',
email: 'john@example.com',
@ -44,6 +45,7 @@ describe('Company mappers', () => {
createdAt: new Date(now.toUTCString()),
employees: graphQLCompany.employees,
address: graphQLCompany.address,
_commentCount: 1,
accountOwner: {
__typename: 'users',
id: '7af20dea-0412-4c4c-8b13-d6f0e6e09e87',
@ -66,6 +68,7 @@ describe('Company mappers', () => {
employees: 10,
address: '1 Infinite Loop, 95014 Cupertino, California, USA',
pipes: [],
_commentCount: 1,
accountOwner: {
id: '522d4ec4-c46b-4360-a0a7-df8df170be81',
email: 'john@example.com',

View File

@ -20,6 +20,8 @@ export type Company = {
pipes?: Pipeline[];
accountOwner?: User | null;
_commentCount?: number;
};
export type GraphqlQueryCompany = {
@ -34,6 +36,8 @@ export type GraphqlQueryCompany = {
accountOwner?: GraphqlQueryUser | null;
pipes?: GraphqlQueryPipeline[] | null;
__typename?: string;
_commentCount?: number;
};
export type GraphqlMutationCompany = {
@ -62,6 +66,8 @@ export const mapToCompany = (company: GraphqlQueryCompany): Company => ({
? mapToUser(company.accountOwner)
: company.accountOwner,
pipes: [],
_commentCount: company._commentCount,
});
export const mapToGqlCompany = (company: Company): GraphqlMutationCompany => ({

View File

@ -22,6 +22,7 @@ export const GET_COMPANIES = gql`
createdAt
address
employees
_commentCount
accountOwner {
id
email