Wip
This commit is contained in:
parent
9af56f3425
commit
e2679ce6b1
|
@ -18,7 +18,7 @@ const DialogCard = (props: DialogProps) => {
|
||||||
title: 'test chat',
|
title: 'test chat',
|
||||||
members: [props.author.slug, props.ownSlug]
|
members: [props.author.slug, props.ownSlug]
|
||||||
})
|
})
|
||||||
console.debug('[initChat]', initChat.data)
|
console.debug('[initChat]', initChat.data.createChat)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,23 +64,26 @@ const handleGetChats = async () => {
|
||||||
|
|
||||||
export const InboxView = () => {
|
export const InboxView = () => {
|
||||||
const [messages, setMessages] = createSignal([])
|
const [messages, setMessages] = createSignal([])
|
||||||
const [authors, setAuthors] = createSignal<Author[]>([])
|
const [recipients, setRecipients] = createSignal<Author[]>([])
|
||||||
const [cashedAuthors, setCashedAuthors] = createSignal<Author[]>([])
|
const [cashedRecipients, setCashedRecipients] = createSignal<Author[]>([])
|
||||||
const [postMessageText, setPostMessageText] = createSignal('')
|
const [postMessageText, setPostMessageText] = createSignal('')
|
||||||
const [loading, setLoading] = createSignal<boolean>(false)
|
const [loading, setLoading] = createSignal<boolean>(false)
|
||||||
// const [currentSlug, setCurrentSlug] = createSignal<Author['slug'] | null>()
|
const [currentSlug, setCurrentSlug] = createSignal<Author['slug'] | null>()
|
||||||
|
|
||||||
const { session } = useSession()
|
const { session } = useSession()
|
||||||
console.log('!!! session:', session())
|
createEffect(() => {
|
||||||
const currentSlug = createMemo(() => session()?.user?.slug)
|
console.log('!!! session:', session())
|
||||||
|
setCurrentSlug(session()?.user?.slug)
|
||||||
|
})
|
||||||
|
console.log('!!! currentSlug:', currentSlug())
|
||||||
|
|
||||||
// Поиск по диалогам
|
// Поиск по диалогам
|
||||||
const getQuery = (query) => {
|
const getQuery = (query) => {
|
||||||
if (query().length >= 2) {
|
if (query().length >= 2) {
|
||||||
const match = userSearch(authors(), query())
|
const match = userSearch(recipients(), query())
|
||||||
setAuthors(match)
|
setRecipients(match)
|
||||||
} else {
|
} else {
|
||||||
setAuthors(cashedAuthors())
|
setRecipients(cashedRecipients())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,8 +112,9 @@ export const InboxView = () => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await loadRecipients({ days: 365 })
|
const response = await loadRecipients({ days: 365 })
|
||||||
setAuthors(response as unknown as Author[])
|
console.log('!!! response:', response)
|
||||||
setCashedAuthors(response as unknown as Author[])
|
setRecipients(response as unknown as Author[])
|
||||||
|
setCashedRecipients(response as unknown as Author[])
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
}
|
}
|
||||||
|
@ -151,7 +155,7 @@ export const InboxView = () => {
|
||||||
</div>
|
</div>
|
||||||
<div class="holder">
|
<div class="holder">
|
||||||
<div class="dialogs">
|
<div class="dialogs">
|
||||||
<For each={authors()}>
|
<For each={recipients()}>
|
||||||
{(author) => <DialogCard ownSlug={currentSlug()} author={author} online={true} />}
|
{(author) => <DialogCard ownSlug={currentSlug()} author={author} online={true} />}
|
||||||
</For>
|
</For>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -9,7 +9,8 @@ import type {
|
||||||
QueryLoadAuthorsByArgs,
|
QueryLoadAuthorsByArgs,
|
||||||
QueryLoadMessagesByArgs,
|
QueryLoadMessagesByArgs,
|
||||||
MutationCreateChatArgs,
|
MutationCreateChatArgs,
|
||||||
MutationCreateMessageArgs
|
MutationCreateMessageArgs,
|
||||||
|
QueryLoadRecipientsArgs
|
||||||
} from '../graphql/types.gen'
|
} from '../graphql/types.gen'
|
||||||
import { publicGraphQLClient } from '../graphql/publicGraphQLClient'
|
import { publicGraphQLClient } from '../graphql/publicGraphQLClient'
|
||||||
import { getToken, privateGraphQLClient } from '../graphql/privateGraphQLClient'
|
import { getToken, privateGraphQLClient } from '../graphql/privateGraphQLClient'
|
||||||
|
@ -286,7 +287,8 @@ export const apiClient = {
|
||||||
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 }) => {
|
getRecipients: async (options: QueryLoadRecipientsArgs) => {
|
||||||
const resp = await privateGraphQLClient.query(loadRecipients, { limit, offset })
|
const resp = await privateGraphQLClient.query(loadRecipients, options).toPromise()
|
||||||
|
return resp.data.loadRecipients.members
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user