diff --git a/src/components/Views/Inbox.tsx b/src/components/Views/Inbox.tsx index 9bdf2437..bdc42edf 100644 --- a/src/components/Views/Inbox.tsx +++ b/src/components/Views/Inbox.tsx @@ -11,7 +11,7 @@ import '../../styles/Inbox.scss' // Для моков 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' const OWNER_ID = '501' @@ -109,7 +109,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 6e83cf87..9cc59067 100644 --- a/src/stores/inbox.ts +++ b/src/stores/inbox.ts @@ -1,7 +1,7 @@ import { apiClient } from '../utils/apiClient' -export const loadAuthorsBy = async (by?: any): 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 }) } }