Skip to content

Commit

Permalink
Merge pull request #1241 from gagansuie/dev
Browse files Browse the repository at this point in the history
Fix: parsing channelId and userid to integers
  • Loading branch information
gagansuie authored May 7, 2024
2 parents 0a2f6c9 + 654e44d commit 44a8b79
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
18 changes: 9 additions & 9 deletions src/lib/websocket.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { env } from '$env/dynamic/public'

const initChannelSocket = ({ channelId }: { channelId: string }) => {
const initChannelSocket = ({ channelId }: { channelId: number }) => {
return new WebSocket(`${env.PUBLIC_WEBSOCKET_URL}/wsinit/channelid/${channelId}/connect`)
}

Expand Down Expand Up @@ -30,9 +30,9 @@ const emitChannelSubscribeByUser = ({
username
}: {
channelSocket: WebSocket
channelId: string
hostId: string
userId: string
channelId: number
hostId: number
userId: number
username: string
}) => {
channelSocket.send(
Expand All @@ -51,7 +51,7 @@ const emitMessageToChannel = ({
message
}: {
channelSocket: WebSocket
channelId: string
channelId: number
message: any
}) => {
channelSocket.send(JSON.stringify({ eventName: `channel-message`, channelId, message }))
Expand All @@ -63,7 +63,7 @@ const emitDeleteMessageToChannel = ({
message
}: {
channelSocket: WebSocket
channelId: string
channelId: number
message: string
}) => {
channelSocket.send(
Expand All @@ -80,7 +80,7 @@ const emitDeleteAllMessagesToChannel = ({
channelId
}: {
channelSocket: WebSocket
channelId: string
channelId: number
}) => {
channelSocket.send(JSON.stringify({ eventName: `delete-all-channel-messages`, channelId }))
}
Expand All @@ -92,7 +92,7 @@ const emitChatHistoryToChannel = ({
cursor
}: {
channelSocket: WebSocket
channelId: string
channelId: number
limit: number
cursor?: string
}) => {
Expand Down Expand Up @@ -124,7 +124,7 @@ const emitReactToMessage = ({
reaction
}: {
channelSocket: WebSocket
channelId: string
channelId: number
message: any
user: any
reaction: string
Expand Down
8 changes: 4 additions & 4 deletions src/routes/channel/[channelId]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,14 @@
if (chan.socket?.readyState === WebSocket.OPEN) {
emitChannelSubscribeByUser({
channelSocket: chan.socket,
channelId: $page.params.channelId,
channelId: parseInt($page.params.channelId),
hostId: chan.userId,
userId: $page.data.user?.userId,
username: $page.data.user?.user?.username
})
emitChatHistoryToChannel({
channelSocket: chan.socket,
channelId: $page.params.channelId,
channelId: parseInt($page.params.channelId),
limit: 100
})
platformPollingInterval = setInterval(async () => {
Expand Down Expand Up @@ -268,7 +268,7 @@
channel.userId === $page.data.user?.userId ||
channel.guests?.includes($page.data.user?.userId)
if (!channel.socket) {
channel.socket = initChannelSocket({ channelId: $page.params.channelId })
channel.socket = initChannelSocket({ channelId: parseInt($page.params.channelId) })
} else {
initChannel(channel)
}
Expand Down Expand Up @@ -321,7 +321,7 @@
})
emitDeleteAllMessagesToChannel({
channelSocket: channel.socket,
channelId: $page.params.channelId
channelId: parseInt($page.params.channelId)
})
goto('/browse')
}
Expand Down

0 comments on commit 44a8b79

Please sign in to comment.