Skip to content

Commit

Permalink
fix: Notification counter now gets updated when reading a dialog (#1398)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdigdir committed Nov 27, 2024
1 parent 2cbf387 commit ed91b61
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/frontend/src/api/useDialogById.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useQuery } from '@tanstack/react-query';
import { useQuery, useQueryClient } from '@tanstack/react-query';
import type {
AttachmentFieldsFragment,
DialogActivityFragment,
Expand Down Expand Up @@ -183,6 +183,7 @@ export function mapDialogDtoToInboxItem(
};
}
export const useDialogById = (parties: PartyFieldsFragment[], id?: string): UseDialogByIdOutput => {
const queryClient = useQueryClient();
const { organizations, isLoading: isOrganizationsLoading } = useOrganizations();
const partyURIs = parties.map((party) => party.party);
const { data, isSuccess, isLoading } = useQuery<GetDialogByIdQuery>({
Expand All @@ -193,6 +194,8 @@ export const useDialogById = (parties: PartyFieldsFragment[], id?: string): UseD
enabled: typeof id !== 'undefined' && partyURIs.length > 0,
});

isSuccess && queryClient.invalidateQueries({ queryKey: [QUERY_KEYS.DIALOGS] });

if (isOrganizationsLoading) {
return { isLoading: true, isSuccess: false };
}
Expand Down

0 comments on commit ed91b61

Please sign in to comment.