From 10b9a4eb4e0ae46cb1f188fa6df8ae04bccda066 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 22 Sep 2022 16:34:20 -0500 Subject: [PATCH] Chats: don't make mark as read hit the API again --- app/soapbox/queries/chats.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/soapbox/queries/chats.ts b/app/soapbox/queries/chats.ts index d327a4eee..0de56b8b4 100644 --- a/app/soapbox/queries/chats.ts +++ b/app/soapbox/queries/chats.ts @@ -8,7 +8,7 @@ import compareId from 'soapbox/compare_id'; import { useChatContext } from 'soapbox/contexts/chat-context'; import { useApi, useAppDispatch, useFeatures } from 'soapbox/hooks'; import { normalizeChatMessage } from 'soapbox/normalizers'; -import { flattenPages } from 'soapbox/utils/queries'; +import { flattenPages, updatePageItem } from 'soapbox/utils/queries'; import { queryClient } from './client'; @@ -155,7 +155,7 @@ const useChat = (chatId: string) => { const markChatAsRead = (lastReadId: string) => { api.post(`/api/v1/pleroma/chats/${chatId}/read`, { last_read_id: lastReadId }) - .then(() => queryClient.invalidateQueries(['chats', 'search'])) + .then(({ data }) => updatePageItem(['chats', 'search'], data, (o, n) => o.id === n.id)) .catch(() => null); };