update-api
This commit is contained in:
parent
6c6b0ccfd2
commit
07f3a65c40
|
@ -11,7 +11,7 @@ import '../../styles/Inbox.scss'
|
||||||
// Для моков
|
// Для моков
|
||||||
import { createClient } from '@urql/core'
|
import { createClient } from '@urql/core'
|
||||||
import Message from '../Inbox/Message'
|
import Message from '../Inbox/Message'
|
||||||
import { loadAuthorsBy, loadChats } from '../../stores/inbox'
|
import { loadRecipients, loadChats } from '../../stores/inbox'
|
||||||
import { t } from '../../utils/intl'
|
import { t } from '../../utils/intl'
|
||||||
|
|
||||||
const OWNER_ID = '501'
|
const OWNER_ID = '501'
|
||||||
|
@ -109,7 +109,7 @@ export const InboxView = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await loadAuthorsBy({ days: 365 })
|
const response = await loadRecipients({ days: 365 })
|
||||||
setAuthors(response as unknown as Author[])
|
setAuthors(response as unknown as Author[])
|
||||||
setCashedAuthors(response as unknown as Author[])
|
setCashedAuthors(response as unknown as Author[])
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
14
src/graphql/query/chat-recipients.ts
Normal file
14
src/graphql/query/chat-recipients.ts
Normal 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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
|
@ -1,7 +1,7 @@
|
||||||
import { apiClient } from '../utils/apiClient'
|
import { apiClient } from '../utils/apiClient'
|
||||||
|
|
||||||
export const loadAuthorsBy = async (by?: any): Promise<void> => {
|
export const loadRecipients = async (by = {}): Promise<void> => {
|
||||||
return await apiClient.getAuthorsBy({ by })
|
return await apiClient.getRecipients(by)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const loadChats = async (): Promise<void> => {
|
export const loadChats = async (): Promise<void> => {
|
||||||
|
|
|
@ -39,6 +39,7 @@ import { REACTIONS_AMOUNT_PER_PAGE } from '../stores/zine/reactions'
|
||||||
import authorsLoadBy from '../graphql/query/authors-load-by'
|
import authorsLoadBy from '../graphql/query/authors-load-by'
|
||||||
import shoutsLoadBy from '../graphql/query/articles-load-by'
|
import shoutsLoadBy from '../graphql/query/articles-load-by'
|
||||||
import shoutLoad from '../graphql/query/articles-load'
|
import shoutLoad from '../graphql/query/articles-load'
|
||||||
|
import loadRecipients from '../graphql/query/chat-recipients'
|
||||||
|
|
||||||
type ApiErrorCode =
|
type ApiErrorCode =
|
||||||
| 'unknown'
|
| 'unknown'
|
||||||
|
@ -284,5 +285,8 @@ export const apiClient = {
|
||||||
getChatMessages: async (options: QueryLoadMessagesByArgs) => {
|
getChatMessages: async (options: QueryLoadMessagesByArgs) => {
|
||||||
const resp = await privateGraphQLClient.query(chatMessagesLoadBy, options).toPromise()
|
const resp = await privateGraphQLClient.query(chatMessagesLoadBy, options).toPromise()
|
||||||
return resp.data.loadChat
|
return resp.data.loadChat
|
||||||
|
},
|
||||||
|
getRecipients: async ({ limit = 50, offset = 0 }) => {
|
||||||
|
const resp = await privateGraphQLClient.query(loadRecipients, { limit, offset })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user