fix-inbox-ws

This commit is contained in:
tonyrewin 2023-01-31 20:31:13 +03:00
parent b4ad24e0cf
commit dbc11b049a
2 changed files with 9 additions and 9 deletions

View File

@ -143,9 +143,9 @@ export const InboxView = () => {
return b.updatedAt - a.updatedAt return b.updatedAt - a.updatedAt
}) })
if (sortByPerToPer()) { if (sortByPerToPer()) {
return sorted.filter((chat) => chat.title.trim().length === 0) return sorted.filter((chat) => Boolean(chat.title?.trim()))
} else if (sortByGroup()) { } else if (sortByGroup()) {
return sorted.filter((chat) => chat.title.trim().length > 0) return sorted.filter((chat) => chat.title?.trim().length > 0)
} else { } else {
return sorted return sorted
} }
@ -157,7 +157,7 @@ export const InboxView = () => {
const handleKeyDown = async (event) => { const handleKeyDown = async (event) => {
if (event.keyCode === 13 && event.shiftKey) return if (event.keyCode === 13 && event.shiftKey) return
if (event.keyCode === 13 && !event.shiftKey && postMessageText().trim().length > 0) { if (event.keyCode === 13 && !event.shiftKey && postMessageText()?.trim().length > 0) {
event.preventDefault() event.preventDefault()
handleSubmit() handleSubmit()
} }

View File

@ -1,10 +1,10 @@
import type { Accessor, JSX } from 'solid-js' import { Accessor, createMemo, JSX } from 'solid-js'
import { createContext, createSignal, useContext } from 'solid-js' import { createContext, createSignal, useContext } from 'solid-js'
// import { createChatClient } from '../graphql/privateGraphQLClient' import { createChatClient } from '../graphql/privateGraphQLClient'
import type { Chat, Message, MutationCreateMessageArgs } from '../graphql/types.gen' import type { Chat, Message, MutationCreateMessageArgs } from '../graphql/types.gen'
import { apiClient } from '../utils/apiClient' import { apiClient } from '../utils/apiClient'
// import newMessage from '../graphql/subs/new-message' import newMessage from '../graphql/subs/new-message'
// import type { Client } from '@urql/core' import type { Client } from '@urql/core'
import { pipe, subscribe } from 'wonka' import { pipe, subscribe } from 'wonka'
import { loadMessages } from '../stores/inbox' import { loadMessages } from '../stores/inbox'
@ -29,7 +29,7 @@ export function useInbox() {
export const InboxProvider = (props: { children: JSX.Element }) => { export const InboxProvider = (props: { children: JSX.Element }) => {
const [chats, setChats] = createSignal<Chat[]>([]) const [chats, setChats] = createSignal<Chat[]>([])
const [messages, setMessages] = createSignal<Message[]>([]) const [messages, setMessages] = createSignal<Message[]>([])
// const subclient = createMemo<Client>(() => createChatClient()) const subclient = createMemo<Client>(() => createChatClient())
const loadChats = async () => { const loadChats = async () => {
try { try {
const newChats = await apiClient.getChats({ limit: 50, offset: 0 }) const newChats = await apiClient.getChats({ limit: 50, offset: 0 })
@ -72,7 +72,7 @@ export const InboxProvider = (props: { children: JSX.Element }) => {
} }
const { unsubscribe } = pipe( const { unsubscribe } = pipe(
() => null, // subclient().subscription(newMessage, {}), () => subclient().subscription(newMessage, {}),
subscribe((result) => { subscribe((result) => {
console.info('[subscription]') console.info('[subscription]')
console.debug(result) console.debug(result)