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