@ethora/chat-component 25.6.10 → 25.6.11

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/dist/main.js CHANGED
@@ -4969,7 +4969,9 @@ const so = (n) => ({
4969
4969
  setLangSource: W1
4970
4970
  } = j1.actions, Hv = j1.reducer, yc = (n, e) => new Date(n) < new Date(e), ao = (n, e) => new Date(n) > new Date(e);
4971
4971
  function Uv(n, e, i) {
4972
- if (n.find((A) => A.id === e.id)) return;
4972
+ if (n.find(
4973
+ (A) => A.id === e.id || e.xmppId && A.id === e.xmppId || A.xmppId && A.xmppId === e.id
4974
+ )) return;
4973
4975
  const r = e.date, s = n[n.length - 1], a = n[0];
4974
4976
  if (ao(r.toString(), s.date.toString())) {
4975
4977
  const A = n.findIndex(
@@ -5109,9 +5111,21 @@ const Jv = {
5109
5111
  const { roomJID: i, message: t, start: r } = e.payload;
5110
5112
  if (!t?.body) return;
5111
5113
  const s = n.rooms[i]?.messages, a = Object.keys(JSON.parse(JSON.stringify(n.rooms))).length > 0, A = !!n?.rooms[i];
5112
- if (!a || !A || (s || (n.rooms[i].messages = []), s.some((f) => f.id === t.id)))
5114
+ if (!a || !A)
5113
5115
  return;
5114
- const o = {
5116
+ s || (n.rooms[i].messages = []);
5117
+ const o = s.findIndex(
5118
+ (d) => d.id === t.id || t.xmppId && d.id === t.xmppId || d.xmppId && d.xmppId === t.id
5119
+ );
5120
+ if (o !== -1) {
5121
+ s[o] = {
5122
+ ...s[o],
5123
+ ...t,
5124
+ pending: !1
5125
+ };
5126
+ return;
5127
+ }
5128
+ const f = {
5115
5129
  ...t,
5116
5130
  user: {
5117
5131
  name: zv(n.usersSet, t.user.id),
@@ -5119,20 +5133,20 @@ const Jv = {
5119
5133
  }
5120
5134
  };
5121
5135
  if (s.length === 0 || r) {
5122
- const f = s.findIndex(
5123
- (d) => d.id === t.xmppId || d.id === t.id
5136
+ const d = s.findIndex(
5137
+ (l) => l.id === t.xmppId || l.id === t.id
5124
5138
  );
5125
- f !== -1 ? s[f] = {
5126
- ...o,
5127
- id: o.id,
5139
+ d !== -1 ? s[d] = {
5140
+ ...f,
5141
+ id: f.id,
5128
5142
  pending: !1
5129
- } : s.unshift(o);
5143
+ } : s.unshift(f);
5130
5144
  } else {
5131
- const f = n.rooms[i].lastViewedTimestamp ? new Date(n.rooms[i].lastViewedTimestamp) : null;
5145
+ const d = n.rooms[i].lastViewedTimestamp ? new Date(n.rooms[i].lastViewedTimestamp) : null;
5132
5146
  Uv(
5133
5147
  s,
5134
- o,
5135
- f
5148
+ f,
5149
+ d
5136
5150
  );
5137
5151
  }
5138
5152
  },