inbox api fixes
This commit is contained in:
parent
4071af4b82
commit
54817e506d
|
@ -1,6 +1,6 @@
|
|||
import type { JSX } from 'solid-js'
|
||||
import { createContext, useContext } from 'solid-js'
|
||||
import type { Message, Chat } from '../graphql/types.gen'
|
||||
import type { Message } from '../graphql/types.gen'
|
||||
import { apiClient } from '../utils/apiClient'
|
||||
import { createStore } from 'solid-js/store'
|
||||
|
||||
|
@ -20,12 +20,12 @@ export function useInbox() {
|
|||
export const InboxProvider = (props: { children: JSX.Element }) => {
|
||||
const [chatEntities, setChatEntities] = createStore({})
|
||||
|
||||
const createChat = async (memberSlugs: string[], title?: string) => {
|
||||
// @ts-ignore FIXME: вывести типы
|
||||
const chat = await apiClient.createChat({ string, title })
|
||||
const createChat = async (members: string[], title?: string) => {
|
||||
const chat = await apiClient.createChat({ members, title })
|
||||
|
||||
// @ts-ignore FIXME: вывести типы
|
||||
setChatEntities(chat.id, chat)
|
||||
setChatEntities((s) => {
|
||||
s[chat.id] = chat
|
||||
})
|
||||
}
|
||||
|
||||
const actions = {
|
||||
|
|
|
@ -41,6 +41,7 @@ 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'
|
||||
import createMessage from '../graphql/mutation/create-chat-message'
|
||||
|
||||
type ApiErrorCode =
|
||||
| 'unknown'
|
||||
|
@ -227,14 +228,6 @@ export const apiClient = {
|
|||
|
||||
// CUDL
|
||||
|
||||
createChat: async (options: MutationCreateChatArgs) => {
|
||||
return await privateGraphQLClient.mutation(createChat, options).toPromise()
|
||||
},
|
||||
|
||||
createMessage: async (options: MutationCreateMessageArgs) => {
|
||||
return await privateGraphQLClient.mutation(createChat, options).toPromise()
|
||||
},
|
||||
|
||||
updateReaction: async ({ reaction }) => {
|
||||
const response = await privateGraphQLClient.mutation(reactionUpdate, { reaction }).toPromise()
|
||||
|
||||
|
@ -283,6 +276,16 @@ export const apiClient = {
|
|||
return resp.data.myChats
|
||||
},
|
||||
|
||||
createChat: async (options: MutationCreateChatArgs) => {
|
||||
const resp = await privateGraphQLClient.mutation(createChat, options).toPromise()
|
||||
return resp.data.createChat
|
||||
},
|
||||
|
||||
createMessage: async (options: MutationCreateMessageArgs) => {
|
||||
const resp = await privateGraphQLClient.mutation(createMessage, options).toPromise()
|
||||
return resp.data.createMessage
|
||||
},
|
||||
|
||||
getChatMessages: async (options: QueryLoadMessagesByArgs) => {
|
||||
const resp = await privateGraphQLClient.query(chatMessagesLoadBy, options).toPromise()
|
||||
return resp.data.loadChat
|
||||
|
|
Loading…
Reference in New Issue
Block a user