@codingfactory/messenger-client 0.2.30 → 0.2.31

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.
Files changed (2) hide show
  1. package/dist/index.js +24 -9
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1018,13 +1018,20 @@ const Qt = Di("messaging", {
1018
1018
  async deleteMessage(e, n) {
1019
1019
  try {
1020
1020
  await W().delete(`/v1/messaging/conversations/${e}/messages/${n}`);
1021
- const r = this.messages[e] || [], o = r.findIndex((c) => c.id === n);
1022
- if (o >= 0) {
1023
- const c = r[o];
1024
- if (!c)
1025
- return;
1026
- const u = { ...c, is_deleted: !0 };
1027
- delete u.body, r[o] = u;
1021
+ const r = this.messages[e];
1022
+ if (r) {
1023
+ const o = r.findIndex((c) => c.id === n);
1024
+ if (o >= 0) {
1025
+ const c = r[o];
1026
+ if (c) {
1027
+ const u = { ...c, is_deleted: !0 };
1028
+ delete u.body, this.messages[e] = [
1029
+ ...r.slice(0, o),
1030
+ u,
1031
+ ...r.slice(o + 1)
1032
+ ];
1033
+ }
1034
+ }
1028
1035
  }
1029
1036
  } catch (r) {
1030
1037
  throw this.error = Z(r), r;
@@ -1284,7 +1291,11 @@ const Qt = Di("messaging", {
1284
1291
  const f = d.findIndex((h) => h.id === n);
1285
1292
  if (f >= 0) {
1286
1293
  const h = d[f];
1287
- h && (d[f] = r(h));
1294
+ h && (this.messages[e] = [
1295
+ ...d.slice(0, f),
1296
+ r(h),
1297
+ ...d.slice(f + 1)
1298
+ ]);
1288
1299
  return;
1289
1300
  }
1290
1301
  o && this.addMessage(o);
@@ -1334,7 +1345,11 @@ const Qt = Di("messaging", {
1334
1345
  const f = u[d];
1335
1346
  if (!f) return;
1336
1347
  const h = { ...f };
1337
- r !== void 0 && (h.body = r), o !== void 0 && (h.edited_at = o), c !== void 0 && (h.meta = c), u[d] = h;
1348
+ r !== void 0 && (h.body = r), o !== void 0 && (h.edited_at = o), c !== void 0 && (h.meta = c), this.messages[e] = [
1349
+ ...u.slice(0, d),
1350
+ h,
1351
+ ...u.slice(d + 1)
1352
+ ];
1338
1353
  const R = this.conversations.find((v) => v.id === e);
1339
1354
  R?.last_message?.id === n && (R.last_message = h);
1340
1355
  const C = this.requests.find((v) => v.id === e);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codingfactory/messenger-client",
3
- "version": "0.2.30",
3
+ "version": "0.2.31",
4
4
  "description": "Shared messaging frontend state, API helpers, and realtime composables.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",