Create chat fix
This commit is contained in:
parent
fe4f55ad11
commit
0caf36268e
|
@ -51,8 +51,8 @@ export const InboxView = () => {
|
||||||
|
|
||||||
let chatWindow
|
let chatWindow
|
||||||
|
|
||||||
const onMessage = (payload) => console.log(payload)
|
const onMessage = (payload) => console.log('!!! payload', payload)
|
||||||
|
// const listener = setListener
|
||||||
const handleOpenChat = async (chat: Chat) => {
|
const handleOpenChat = async (chat: Chat) => {
|
||||||
setCurrentDialog(chat)
|
setCurrentDialog(chat)
|
||||||
try {
|
try {
|
||||||
|
@ -99,18 +99,16 @@ export const InboxView = () => {
|
||||||
const { actions } = useInbox()
|
const { actions } = useInbox()
|
||||||
const urlParams = new URLSearchParams(window.location.search)
|
const urlParams = new URLSearchParams(window.location.search)
|
||||||
const params = Object.fromEntries(urlParams)
|
const params = Object.fromEntries(urlParams)
|
||||||
console.log('!!! params:', params)
|
|
||||||
|
|
||||||
createEffect(async () => {
|
createEffect(async () => {
|
||||||
if (textareaParent) {
|
if (textareaParent) {
|
||||||
textareaParent.dataset.replicatedValue = postMessageText()
|
textareaParent.dataset.replicatedValue = postMessageText()
|
||||||
}
|
}
|
||||||
if (params['openChat']) {
|
if (params['openChat']) {
|
||||||
try {
|
try {
|
||||||
const newChat = await actions.createChat([Number(params['chat'])], '')
|
const newChat = await actions.createChat([Number(params['openChat'])], '')
|
||||||
console.log('!!! newChat:', newChat)
|
|
||||||
await handleOpenChat(newChat.chat)
|
|
||||||
await loadChats()
|
await loadChats()
|
||||||
|
const chatToOpen = chats().find((chat) => chat.id === newChat.chat.id)
|
||||||
|
await handleOpenChat(chatToOpen)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,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 [listener, setListener] = createSignal(console.debug)
|
const [listener, setListener] = createSignal()
|
||||||
const subclient = createMemo(() => createChatClient(listener()))
|
const subclient = createMemo(() => createChatClient(listener()))
|
||||||
const loadChats = async () => {
|
const loadChats = async () => {
|
||||||
try {
|
try {
|
||||||
|
@ -52,7 +52,7 @@ export const InboxProvider = (props: { children: JSX.Element }) => {
|
||||||
}
|
}
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
const resp = subclient().subscription(newMessages, {})
|
const resp = subclient().subscription(newMessages, {})
|
||||||
console.debug(resp)
|
console.log(resp) // onMount
|
||||||
})
|
})
|
||||||
const value: InboxContextType = { chats, actions }
|
const value: InboxContextType = { chats, actions }
|
||||||
return <InboxContext.Provider value={value}>{props.children}</InboxContext.Provider>
|
return <InboxContext.Provider value={value}>{props.children}</InboxContext.Provider>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user