Refresh comments threads and count on new comment (#276)
* Refresh comments threads and count on new comment * Fix tests
This commit is contained in:
@ -70,8 +70,8 @@ export function CommentThread({ commentThread }: OwnProps) {
|
||||
// Also it cannot refetch queries than are not in the cache
|
||||
refetchQueries: [
|
||||
'GetCommentThreadsByTargets',
|
||||
'GetPeopleCommentsCount',
|
||||
'GetCompanyCommentsCount',
|
||||
'GetCompanies',
|
||||
'GetPeople',
|
||||
],
|
||||
onError: (error) => {
|
||||
logError(
|
||||
|
||||
@ -6,6 +6,7 @@ import { currentUserState } from '@/auth/states/currentUserState';
|
||||
import { commentableEntityArrayState } from '@/comments/states/commentableEntityArrayState';
|
||||
import { createdCommentThreadIdState } from '@/comments/states/createdCommentThreadIdState';
|
||||
import { AutosizeTextInput } from '@/ui/components/inputs/AutosizeTextInput';
|
||||
import { useOpenRightDrawer } from '@/ui/layout/right-drawer/hooks/useOpenRightDrawer';
|
||||
import { logError } from '@/utils/logs/logError';
|
||||
import { isDefined } from '@/utils/type-guards/isDefined';
|
||||
import { isNonEmptyString } from '@/utils/type-guards/isNonEmptyString';
|
||||
@ -49,6 +50,8 @@ export function CommentThreadCreateMode() {
|
||||
createdCommentThreadIdState,
|
||||
);
|
||||
|
||||
const openRightDrawer = useOpenRightDrawer();
|
||||
|
||||
const [createCommentMutation] = useCreateCommentMutation();
|
||||
|
||||
const [createCommentThreadWithComment] =
|
||||
@ -96,9 +99,10 @@ export function CommentThreadCreateMode() {
|
||||
}),
|
||||
),
|
||||
},
|
||||
refetchQueries: ['GetCommentThread'],
|
||||
refetchQueries: ['GetCommentThread', 'GetCompanies', 'GetPeople'],
|
||||
onCompleted(data) {
|
||||
setCreatedCommentThreadId(data.createOneCommentThread.id);
|
||||
openRightDrawer('comments');
|
||||
},
|
||||
});
|
||||
} else {
|
||||
@ -111,11 +115,7 @@ export function CommentThreadCreateMode() {
|
||||
createdAt: new Date().toISOString(),
|
||||
},
|
||||
// TODO: find a way to have this configuration dynamic and typed
|
||||
refetchQueries: [
|
||||
'GetCommentThread',
|
||||
'GetPeopleCommentsCount',
|
||||
'GetCompanyCommentsCount',
|
||||
],
|
||||
refetchQueries: ['GetCommentThread'],
|
||||
onError: (error) => {
|
||||
logError(
|
||||
`In handleCreateCommentThread, createCommentMutation onError, error: ${error}`,
|
||||
|
||||
@ -4,7 +4,10 @@ import { CommentThreadForDrawer } from '@/comments/types/CommentThreadForDrawer'
|
||||
import { RightDrawerBody } from '@/ui/layout/right-drawer/components/RightDrawerBody';
|
||||
import { RightDrawerPage } from '@/ui/layout/right-drawer/components/RightDrawerPage';
|
||||
import { RightDrawerTopBar } from '@/ui/layout/right-drawer/components/RightDrawerTopBar';
|
||||
import { useGetCommentThreadsByTargetsQuery } from '~/generated/graphql';
|
||||
import {
|
||||
SortOrder,
|
||||
useGetCommentThreadsByTargetsQuery,
|
||||
} from '~/generated/graphql';
|
||||
|
||||
import { commentableEntityArrayState } from '../../states/commentableEntityArrayState';
|
||||
|
||||
@ -18,6 +21,11 @@ export function RightDrawerComments() {
|
||||
commentThreadTargetIds: commentableEntityArray.map(
|
||||
(commentableEntity) => commentableEntity.id,
|
||||
),
|
||||
orderBy: [
|
||||
{
|
||||
createdAt: SortOrder.Desc,
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user