update-api

This commit is contained in:
tonyrewin 2022-11-24 12:06:48 +03:00
parent 6c6b0ccfd2
commit 07f3a65c40
4 changed files with 22 additions and 4 deletions

View File

@ -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) {

View File

@ -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
}
}
`

View File

@ -1,7 +1,7 @@
import { apiClient } from '../utils/apiClient'
export const loadAuthorsBy = async (by?: any): Promise<void> => {
return await apiClient.getAuthorsBy({ by })
export const loadRecipients = async (by = {}): Promise<void> => {
return await apiClient.getRecipients(by)
}
export const loadChats = async (): Promise<void> => {

View File

@ -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 })
}
}