@chat21/chat21-ionic 3.4.27-rc23 → 3.4.27-rc24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -38,7 +38,7 @@ export class WebSocketJs {
|
|
|
38
38
|
const sub = this.subscriptions.get(msg.topic);
|
|
39
39
|
if (!sub) return;
|
|
40
40
|
|
|
41
|
-
let object = { event: msg.payload, data: msg };
|
|
41
|
+
let object = { event: msg.payload, data: msg.data };
|
|
42
42
|
switch (msg.method) {
|
|
43
43
|
case 'CREATE': sub.onCreate?.(msg.payload, object); break;
|
|
44
44
|
case 'UPDATE': sub.onUpdate?.(msg.payload, object); break;
|
|
@@ -151,7 +151,23 @@ function handleMessage(msg: WSMessage) {
|
|
|
151
151
|
|
|
152
152
|
if (!topic) return;
|
|
153
153
|
|
|
154
|
+
// --- GESTIONE ARRAY DI MESSAGGI ---
|
|
155
|
+
const messages = Array.isArray(msg.payload.message) ? msg.payload.message : [msg.payload.message];
|
|
154
156
|
// Notifica solo le subscription che matchano
|
|
157
|
+
subscriptions.forEach(sub => {
|
|
158
|
+
if (sub.topic === topic) {
|
|
159
|
+
messages.forEach(element => {
|
|
160
|
+
postMessage({
|
|
161
|
+
topic,
|
|
162
|
+
method,
|
|
163
|
+
payload: element, // singolo elemento
|
|
164
|
+
data: msg // payload completo per eventuali onData globali
|
|
165
|
+
}, undefined);
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
|
|
155
171
|
subscriptions.forEach(sub => {
|
|
156
172
|
if (sub.topic === topic) {
|
|
157
173
|
postMessage({ topic, method, payload, msg }, undefined);
|