try to implement shoutbox composing idk if it works

Signed-off-by: Nicole Mikołajczyk <git@mkljczk.pl>
This commit is contained in:
Nicole Mikołajczyk
2025-04-01 20:28:38 +02:00
parent de39283b51
commit 1f00bd110f
5 changed files with 18 additions and 29 deletions

View File

@@ -2775,6 +2775,7 @@ class PlApiClient {
onMessages: (messages: Array<ShoutMessage>) => void;
onMessage: (message: ShoutMessage) => void;
}) => {
let counter = 0;
if (this.#shoutSocket) return this.#shoutSocket;
const path = buildFullPath('/socket/websocket', this.baseURL, { token, vsn: '2.0.0' });
@@ -2798,7 +2799,8 @@ class PlApiClient {
this.#shoutSocket = {
message: (text: string) => {
ws.send(JSON.stringify({ type: 'message', text }));
// guess this is meant to be incremented on each call but idk
ws.send(JSON.stringify(['3', `${++counter}`, 'chat:public', 'new_msg', { 'text': text }]));
},
close: () => {
ws.close();

View File

@@ -1,6 +1,6 @@
{
"name": "pl-api",
"version": "1.0.0-rc.35",
"version": "1.0.0-rc.36",
"type": "module",
"homepage": "https://github.com/mkljczk/pl-fe/tree/develop/packages/pl-api",
"repository": {