bun+fixes
This commit is contained in:
parent
5d749c09a7
commit
4650469247
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -14,3 +14,4 @@ src/graphql/introspec.gen.ts
|
|||
stats.html
|
||||
*.scss.d.ts
|
||||
pnpm-lock.yaml
|
||||
bun.lockb
|
13419
package-lock.json
generated
13419
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
|
@ -28,16 +28,15 @@ export const InboxProvider = (props: { children: JSX.Element }) => {
|
|||
const [chats, setChats] = createSignal<Chat[]>([])
|
||||
const [messages, setMessages] = createSignal<Message[]>([])
|
||||
|
||||
fetchEventSource('https://chat.discours.io/connect', {
|
||||
fetchEventSource('https://connect.discours.io', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': getToken()
|
||||
Authorization: getToken()
|
||||
},
|
||||
body: JSON.stringify({
|
||||
foo: 'bar'
|
||||
}),
|
||||
// signal: signal, TODO: sometimes need to call /disconnect
|
||||
onmessage(event) {
|
||||
const message = JSON.parse(event.data)
|
||||
|
||||
|
@ -47,14 +46,17 @@ export const InboxProvider = (props: { children: JSX.Element }) => {
|
|||
},
|
||||
onclose() {
|
||||
// if no error thrown - it will reconnect
|
||||
console.log("sse connection closed")
|
||||
console.log('sse connection closed by server')
|
||||
},
|
||||
onerror(err) {
|
||||
console.warn(err)
|
||||
console.error('sse connection closed by error')
|
||||
throw new Error() // hack to close the connection
|
||||
}
|
||||
})
|
||||
|
||||
// TODO: maybe sometimes need to call /disconnect
|
||||
|
||||
const loadChats = async () => {
|
||||
try {
|
||||
const newChats = await inboxClient.getChats({ limit: 50, offset: 0 })
|
||||
|
@ -101,7 +103,6 @@ export const InboxProvider = (props: { children: JSX.Element }) => {
|
|||
loadChats,
|
||||
getMessages,
|
||||
sendMessage
|
||||
// unsubscribe // TODO: call unsubscribe some time!
|
||||
}
|
||||
|
||||
const value: InboxContextType = { chats, messages, actions }
|
||||
|
|
Loading…
Reference in New Issue
Block a user