From dbc11b049a73888a7a5d29cb6c0d7b1931bee463 Mon Sep 17 00:00:00 2001 From: tonyrewin Date: Tue, 31 Jan 2023 20:31:13 +0300 Subject: [PATCH] fix-inbox-ws --- src/components/Views/Inbox.tsx | 6 +++--- src/context/inbox.tsx | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/components/Views/Inbox.tsx b/src/components/Views/Inbox.tsx index 03df14d7..e49c421f 100644 --- a/src/components/Views/Inbox.tsx +++ b/src/components/Views/Inbox.tsx @@ -143,9 +143,9 @@ export const InboxView = () => { return b.updatedAt - a.updatedAt }) if (sortByPerToPer()) { - return sorted.filter((chat) => chat.title.trim().length === 0) + return sorted.filter((chat) => Boolean(chat.title?.trim())) } else if (sortByGroup()) { - return sorted.filter((chat) => chat.title.trim().length > 0) + return sorted.filter((chat) => chat.title?.trim().length > 0) } else { return sorted } @@ -157,7 +157,7 @@ export const InboxView = () => { const handleKeyDown = async (event) => { 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() handleSubmit() } diff --git a/src/context/inbox.tsx b/src/context/inbox.tsx index 981470d1..a3943bde 100644 --- a/src/context/inbox.tsx +++ b/src/context/inbox.tsx @@ -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 { createChatClient } from '../graphql/privateGraphQLClient' +import { createChatClient } from '../graphql/privateGraphQLClient' import type { Chat, Message, MutationCreateMessageArgs } from '../graphql/types.gen' import { apiClient } from '../utils/apiClient' -// import newMessage from '../graphql/subs/new-message' -// import type { Client } from '@urql/core' +import newMessage from '../graphql/subs/new-message' +import type { Client } from '@urql/core' import { pipe, subscribe } from 'wonka' import { loadMessages } from '../stores/inbox' @@ -29,7 +29,7 @@ export function useInbox() { export const InboxProvider = (props: { children: JSX.Element }) => { const [chats, setChats] = createSignal([]) const [messages, setMessages] = createSignal([]) - // const subclient = createMemo(() => createChatClient()) + const subclient = createMemo(() => createChatClient()) const loadChats = async () => { try { const newChats = await apiClient.getChats({ limit: 50, offset: 0 }) @@ -72,7 +72,7 @@ export const InboxProvider = (props: { children: JSX.Element }) => { } const { unsubscribe } = pipe( - () => null, // subclient().subscription(newMessage, {}), + () => subclient().subscription(newMessage, {}), subscribe((result) => { console.info('[subscription]') console.debug(result)