From c12999a4388ef851a9f015e0ce66f88325481527 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 22 Sep 2022 16:04:52 -0500 Subject: [PATCH] Chats: use v2 endpoint if supported --- app/soapbox/queries/chats.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/soapbox/queries/chats.ts b/app/soapbox/queries/chats.ts index 0c472b36d..784fbb5e5 100644 --- a/app/soapbox/queries/chats.ts +++ b/app/soapbox/queries/chats.ts @@ -6,7 +6,7 @@ import snackbar from 'soapbox/actions/snackbar'; import { getNextLink } from 'soapbox/api'; import compareId from 'soapbox/compare_id'; import { useChatContext } from 'soapbox/contexts/chat-context'; -import { useApi, useAppDispatch } from 'soapbox/hooks'; +import { useApi, useAppDispatch, useFeatures } from 'soapbox/hooks'; import { normalizeChatMessage } from 'soapbox/normalizers'; import { queryClient } from './client'; @@ -102,10 +102,12 @@ const useChatMessages = (chatId: string) => { const useChats = (search?: string) => { const api = useApi(); const dispatch = useAppDispatch(); + const features = useFeatures(); const getChats = async(pageParam?: any): Promise> => { + const endpoint = features.chatsV2 ? '/api/v2/pleroma/chats' : '/api/v1/pleroma/chats'; const nextPageLink = pageParam?.link; - const uri = nextPageLink || '/api/v1/pleroma/chats'; + const uri = nextPageLink || endpoint; const response = await api.get(uri, { params: { search,