diff --git a/src/components/Views/Inbox.tsx b/src/components/Views/Inbox.tsx index 7a43f823..5c0fbfaa 100644 --- a/src/components/Views/Inbox.tsx +++ b/src/components/Views/Inbox.tsx @@ -8,7 +8,7 @@ import Search from '../Inbox/Search' import { useSession } from '../../context/session' import { createClient } from '@urql/core' import Message from '../Inbox/Message' -import { loadAuthorsBy, loadChats } from '../../stores/inbox' +import { loadRecipients, loadChats } from '../../stores/inbox' import { t } from '../../utils/intl' import '../../styles/Inbox.scss' @@ -108,7 +108,7 @@ export const InboxView = () => { } try { - const response = await loadAuthorsBy({ days: 365 }) + const response = await loadRecipients({ days: 365 }) setAuthors(response as unknown as Author[]) setCashedAuthors(response as unknown as Author[]) } catch (error) { diff --git a/src/graphql/query/chat-recipients.ts b/src/graphql/query/chat-recipients.ts new file mode 100644 index 00000000..7acf3588 --- /dev/null +++ b/src/graphql/query/chat-recipients.ts @@ -0,0 +1,14 @@ +import { gql } from '@urql/core' + +export default gql` + query GetChatsQuery($limit: Int, $offset: Int) { + loadRecipients(limit: $limit, offset: $offset) { + members { + name + slug + userpic + } + error + } + } +` diff --git a/src/stores/inbox.ts b/src/stores/inbox.ts index 9c6bcd85..9cc59067 100644 --- a/src/stores/inbox.ts +++ b/src/stores/inbox.ts @@ -1,8 +1,7 @@ import { apiClient } from '../utils/apiClient' -import type { AuthorsBy } from '../graphql/types.gen' -export const loadAuthorsBy = async (by: AuthorsBy): Promise => { - return await apiClient.getAuthorsBy({ by }) +export const loadRecipients = async (by = {}): Promise => { + return await apiClient.getRecipients(by) } export const loadChats = async (): Promise => { diff --git a/src/utils/apiClient.ts b/src/utils/apiClient.ts index 8bf6b590..152ce280 100644 --- a/src/utils/apiClient.ts +++ b/src/utils/apiClient.ts @@ -39,6 +39,7 @@ import { REACTIONS_AMOUNT_PER_PAGE } from '../stores/zine/reactions' import authorsLoadBy from '../graphql/query/authors-load-by' import shoutsLoadBy from '../graphql/query/articles-load-by' import shoutLoad from '../graphql/query/articles-load' +import loadRecipients from '../graphql/query/chat-recipients' type ApiErrorCode = | 'unknown' @@ -284,5 +285,8 @@ export const apiClient = { getChatMessages: async (options: QueryLoadMessagesByArgs) => { const resp = await privateGraphQLClient.query(chatMessagesLoadBy, options).toPromise() return resp.data.loadChat + }, + getRecipients: async ({ limit = 50, offset = 0 }) => { + const resp = await privateGraphQLClient.query(loadRecipients, { limit, offset }) } }