@bcc-code/vue-bcc-chat-ui 7.1.35 → 7.1.37
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/vue-bcc-chat-ui.js +220 -216
- package/dist/vue-bcc-chat-ui.js.map +1 -1
- package/package.json +1 -1
package/dist/vue-bcc-chat-ui.js
CHANGED
|
@@ -4173,7 +4173,7 @@ function cc({ environment: e }) {
|
|
|
4173
4173
|
p.value = !1, ye();
|
|
4174
4174
|
return;
|
|
4175
4175
|
}
|
|
4176
|
-
se = !0, V ||
|
|
4176
|
+
se = !0, V || Ce(!0);
|
|
4177
4177
|
}
|
|
4178
4178
|
}
|
|
4179
4179
|
function ee(e) {
|
|
@@ -4194,10 +4194,10 @@ function cc({ environment: e }) {
|
|
|
4194
4194
|
let I = n(() => v.value.find((e) => e.id === T.value) ?? null), te = `bcc-ui-connection-${crypto.randomUUID()}`, L = `bcc-ui-message-${crypto.randomUUID()}`, R = !1, z = !1, ne = null, B = null, re = null, ie = null, ae = 0, oe = 0, se = !1, V = !1, U = null, ce = /* @__PURE__ */ new Map(), le = /* @__PURE__ */ new Set(), ue = null, de = null, fe = 0;
|
|
4195
4195
|
async function pe() {
|
|
4196
4196
|
if (await lc(e), t.value) {
|
|
4197
|
-
await
|
|
4197
|
+
await ft();
|
|
4198
4198
|
return;
|
|
4199
4199
|
}
|
|
4200
|
-
ve(),
|
|
4200
|
+
ve(), pt(), t.value = !0, await ft(), _.value && (dt(_.value.uid), ge(), Ee(), !m.value && !V && we());
|
|
4201
4201
|
}
|
|
4202
4202
|
async function me(e) {
|
|
4203
4203
|
g.value = null, r.value = !0;
|
|
@@ -4206,9 +4206,9 @@ function cc({ environment: e }) {
|
|
|
4206
4206
|
let t = qe();
|
|
4207
4207
|
await H.getLoggedinUser() && t !== e && await H.logout(), Je(e);
|
|
4208
4208
|
let n = await uc(e);
|
|
4209
|
-
_.value = hc(await H.login(n)), dt(_.value.uid), h.value = !0, m.value = typeof navigator < "u" ? !navigator.onLine : !1, ge(),
|
|
4209
|
+
_.value = hc(await H.login(n)), dt(_.value.uid), h.value = !0, m.value = typeof navigator < "u" ? !navigator.onLine : !1, ge(), Ee(), V || await we(), await Ae(), Jt();
|
|
4210
4210
|
} catch (e) {
|
|
4211
|
-
throw
|
|
4211
|
+
throw Ct(), g.value = Z(e, "Unable to sign in to chat."), e;
|
|
4212
4212
|
} finally {
|
|
4213
4213
|
r.value = !1;
|
|
4214
4214
|
}
|
|
@@ -4218,7 +4218,7 @@ function cc({ environment: e }) {
|
|
|
4218
4218
|
try {
|
|
4219
4219
|
Je(null), Qe(), await H.getLoggedinUser() && await H.logout();
|
|
4220
4220
|
} finally {
|
|
4221
|
-
|
|
4221
|
+
Ct();
|
|
4222
4222
|
}
|
|
4223
4223
|
}
|
|
4224
4224
|
function ge() {
|
|
@@ -4251,22 +4251,20 @@ function cc({ environment: e }) {
|
|
|
4251
4251
|
function xe() {
|
|
4252
4252
|
return Date.now() < ae;
|
|
4253
4253
|
}
|
|
4254
|
-
function Se(
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
return;
|
|
4260
|
-
}
|
|
4261
|
-
if (ne !== null || B || m.value || !h.value || V) return;
|
|
4254
|
+
function Se() {
|
|
4255
|
+
return !!qe();
|
|
4256
|
+
}
|
|
4257
|
+
function Ce(e = !1) {
|
|
4258
|
+
if (ne !== null || B || m.value || V || !h.value && !Se()) return;
|
|
4262
4259
|
let t = e ? 0 : Math.min(3e4, 1e3 * 2 ** Math.min(oe, 4));
|
|
4263
4260
|
ne = setTimeout(() => {
|
|
4264
|
-
ne = null,
|
|
4261
|
+
ne = null, we();
|
|
4265
4262
|
}, t);
|
|
4266
4263
|
}
|
|
4267
|
-
async function
|
|
4268
|
-
if (N(), !(m.value || !h.value
|
|
4264
|
+
async function we() {
|
|
4265
|
+
if (N(), !(m.value || V || !h.value && !Se())) return B || (B = (async () => {
|
|
4269
4266
|
ye();
|
|
4267
|
+
let e = !1;
|
|
4270
4268
|
try {
|
|
4271
4269
|
let e = await H.getLoggedinUser();
|
|
4272
4270
|
if (!e) {
|
|
@@ -4277,45 +4275,46 @@ function cc({ environment: e }) {
|
|
|
4277
4275
|
}
|
|
4278
4276
|
_.value = hc(e), h.value = !0, ge();
|
|
4279
4277
|
let t = H.connect;
|
|
4280
|
-
typeof t == "function" && (await t.call(H), p.value = !0), oe = 0, se && await
|
|
4281
|
-
} catch (
|
|
4282
|
-
p.value = !1, oe += 1,
|
|
4278
|
+
typeof t == "function" && (await t.call(H), p.value = !0), oe = 0, se && await Te();
|
|
4279
|
+
} catch (t) {
|
|
4280
|
+
p.value = !1, oe += 1, Rt(t) || (g.value = Z(t, "Unable to reconnect to chat.")), e = !0;
|
|
4283
4281
|
} finally {
|
|
4284
4282
|
B = null;
|
|
4285
4283
|
}
|
|
4284
|
+
e && Ce();
|
|
4286
4285
|
})(), B);
|
|
4287
4286
|
}
|
|
4288
|
-
async function
|
|
4289
|
-
return re || m.value || !h.value
|
|
4287
|
+
async function Te() {
|
|
4288
|
+
return re || m.value || V || !h.value && !Se() || (re = (async () => {
|
|
4290
4289
|
se = !1, g.value = null;
|
|
4291
4290
|
try {
|
|
4292
|
-
await
|
|
4291
|
+
await Ae(), Jt();
|
|
4293
4292
|
} finally {
|
|
4294
4293
|
re = null;
|
|
4295
4294
|
}
|
|
4296
4295
|
})()), re;
|
|
4297
4296
|
}
|
|
4298
|
-
function
|
|
4297
|
+
function Ee() {
|
|
4299
4298
|
if (!U || v.value.length > 0) return;
|
|
4300
4299
|
let e = U.getConversations();
|
|
4301
|
-
e.length !== 0 && (v.value = bc(e), !T.value && v.value.length > 0 &&
|
|
4300
|
+
e.length !== 0 && (v.value = bc(e), !T.value && v.value.length > 0 && De(T.value));
|
|
4302
4301
|
}
|
|
4303
|
-
function
|
|
4302
|
+
function De(e) {
|
|
4304
4303
|
if (!U || !e) return y.value = [], !1;
|
|
4305
4304
|
let t = U.getMessages(e).sort(xc);
|
|
4306
4305
|
return y.value = t, t.length > 0;
|
|
4307
4306
|
}
|
|
4308
|
-
async function De() {
|
|
4309
|
-
V = !1, se = !0, await Ce();
|
|
4310
|
-
}
|
|
4311
4307
|
async function Oe() {
|
|
4308
|
+
V = !1, se = !0, await we();
|
|
4309
|
+
}
|
|
4310
|
+
async function ke() {
|
|
4312
4311
|
V = !0, se = !1, ye();
|
|
4313
4312
|
let e = H.disconnect;
|
|
4314
4313
|
typeof e == "function" && await e.call(H), p.value = !1;
|
|
4315
4314
|
}
|
|
4316
|
-
async function
|
|
4315
|
+
async function Ae() {
|
|
4317
4316
|
if (await pe(), N(), i.value = !0, g.value = null, m.value) {
|
|
4318
|
-
v.value = bc(U?.getConversations() ?? []), I.value && await
|
|
4317
|
+
v.value = bc(U?.getConversations() ?? []), I.value && await it(), i.value = !1;
|
|
4319
4318
|
return;
|
|
4320
4319
|
}
|
|
4321
4320
|
try {
|
|
@@ -4328,7 +4327,7 @@ function cc({ environment: e }) {
|
|
|
4328
4327
|
let t = r.get(e.id);
|
|
4329
4328
|
t && (e.subtitle === "No messages yet" && t.subtitle && t.subtitle !== "No messages yet" && (e.subtitle = t.subtitle), !e.lastMessageAt && t.lastMessageAt && (e.lastMessageAt = t.lastMessageAt), !e.lastMessage && t.lastMessage && (e.lastMessage = t.lastMessage));
|
|
4330
4329
|
}
|
|
4331
|
-
v.value = bc(await
|
|
4330
|
+
v.value = bc(await ht(t)), U?.setConversations(v.value), I.value && await it();
|
|
4332
4331
|
} catch (e) {
|
|
4333
4332
|
let t = U?.getConversations() ?? [];
|
|
4334
4333
|
if (t.length > 0) {
|
|
@@ -4340,39 +4339,39 @@ function cc({ environment: e }) {
|
|
|
4340
4339
|
i.value = !1;
|
|
4341
4340
|
}
|
|
4342
4341
|
}
|
|
4343
|
-
async function
|
|
4344
|
-
T.value = e, E.value = null, b.value = [], de = null, C.value = !1, D.value = null, O.value = null,
|
|
4342
|
+
async function je(e) {
|
|
4343
|
+
T.value = e, E.value = null, b.value = [], de = null, C.value = !1, D.value = null, O.value = null, De(e), await it();
|
|
4345
4344
|
}
|
|
4346
|
-
function
|
|
4345
|
+
function Me(e) {
|
|
4347
4346
|
e && (O.value = null), D.value = e;
|
|
4348
4347
|
}
|
|
4349
|
-
function
|
|
4348
|
+
function Ne(e) {
|
|
4350
4349
|
e && (D.value = null), O.value = e;
|
|
4351
4350
|
}
|
|
4352
|
-
async function
|
|
4353
|
-
E.value = e, de = null, C.value = !1, D.value = null, O.value = null, await
|
|
4351
|
+
async function Pe(e) {
|
|
4352
|
+
E.value = e, de = null, C.value = !1, D.value = null, O.value = null, await ot(e.id);
|
|
4354
4353
|
}
|
|
4355
|
-
function
|
|
4354
|
+
function Fe() {
|
|
4356
4355
|
E.value = null, b.value = [], de = null, C.value = !1, D.value = null, O.value = null;
|
|
4357
4356
|
}
|
|
4358
|
-
async function
|
|
4357
|
+
async function Ie(e, t) {
|
|
4359
4358
|
if (u.value) return;
|
|
4360
4359
|
let n = I.value;
|
|
4361
4360
|
if (!n) return;
|
|
4362
4361
|
let r = Vs(e);
|
|
4363
4362
|
if (!Hs(r)) return;
|
|
4364
4363
|
if (O.value) {
|
|
4365
|
-
await
|
|
4364
|
+
await Le(O.value, r);
|
|
4366
4365
|
return;
|
|
4367
4366
|
}
|
|
4368
|
-
let i = E.value?.id, a = crypto.randomUUID(), o = Dc(
|
|
4367
|
+
let i = E.value?.id, a = crypto.randomUUID(), o = Dc(It(D.value, t), a);
|
|
4369
4368
|
u.value = !0, g.value = null;
|
|
4370
4369
|
try {
|
|
4371
4370
|
if (m.value) {
|
|
4372
|
-
|
|
4371
|
+
zt(n, r, o, i, a), D.value = null;
|
|
4373
4372
|
return;
|
|
4374
4373
|
}
|
|
4375
|
-
|
|
4374
|
+
Gt(Ft({
|
|
4376
4375
|
conversation: n,
|
|
4377
4376
|
kind: "text",
|
|
4378
4377
|
text: r,
|
|
@@ -4384,18 +4383,18 @@ function cc({ environment: e }) {
|
|
|
4384
4383
|
let e = new H.TextMessage(n.targetId, r, kc(n));
|
|
4385
4384
|
e.setMuid?.(a), Object.keys(o).length > 0 && e.setMetadata?.(o), i && e.setParentMessageId?.(Number(i));
|
|
4386
4385
|
let t = await H.sendMessage(e);
|
|
4387
|
-
|
|
4386
|
+
Tt(F(t, _.value?.uid)), _t(t), await bt(t), D.value = null;
|
|
4388
4387
|
} catch (e) {
|
|
4389
|
-
if (
|
|
4390
|
-
|
|
4388
|
+
if (Rt(e)) {
|
|
4389
|
+
Kt("queued", a), zt(n, r, o, E.value?.id, a), D.value = null;
|
|
4391
4390
|
return;
|
|
4392
4391
|
}
|
|
4393
|
-
throw
|
|
4392
|
+
throw Kt("failed", a), g.value = Z(e, "Unable to send the message."), e;
|
|
4394
4393
|
} finally {
|
|
4395
4394
|
u.value = !1;
|
|
4396
4395
|
}
|
|
4397
4396
|
}
|
|
4398
|
-
async function
|
|
4397
|
+
async function Le(e, t) {
|
|
4399
4398
|
let n = I.value;
|
|
4400
4399
|
if (!n || m.value) return;
|
|
4401
4400
|
let r = Vs(t);
|
|
@@ -4405,7 +4404,7 @@ function cc({ environment: e }) {
|
|
|
4405
4404
|
let t;
|
|
4406
4405
|
e.kind === "text" ? t = new H.TextMessage(n.targetId, r, kc(n)) : (t = new H.MediaMessage(n.targetId, e.source?.getAttachment?.()?.getFileUrl?.() ?? e.source?.getAttachment?.()?.getUrl?.() ?? e.attachments[0]?.url ?? "", e.source?.getType?.() ?? e.type ?? e.kind, kc(n)), t.setCaption(r)), t.setId(Number(e.id));
|
|
4407
4406
|
let i = await H.editMessage(t);
|
|
4408
|
-
|
|
4407
|
+
Tt(F(i, _.value?.uid)), _t(i), O.value = null;
|
|
4409
4408
|
} catch (e) {
|
|
4410
4409
|
throw g.value = Z(e, "Unable to edit the message."), e;
|
|
4411
4410
|
} finally {
|
|
@@ -4413,18 +4412,18 @@ function cc({ environment: e }) {
|
|
|
4413
4412
|
}
|
|
4414
4413
|
}
|
|
4415
4414
|
}
|
|
4416
|
-
async function
|
|
4415
|
+
async function Re(e, t) {
|
|
4417
4416
|
if (u.value) return;
|
|
4418
4417
|
let n = I.value;
|
|
4419
4418
|
if (!n) return;
|
|
4420
|
-
let r = E.value?.id, i = crypto.randomUUID(), a = Dc(
|
|
4419
|
+
let r = E.value?.id, i = crypto.randomUUID(), a = Dc(It(D.value, t), i), o = Nc(e.file);
|
|
4421
4420
|
u.value = !0, g.value = null;
|
|
4422
4421
|
try {
|
|
4423
4422
|
if (m.value) {
|
|
4424
|
-
await
|
|
4423
|
+
await Ut(n, e, a, r, i), D.value = null;
|
|
4425
4424
|
return;
|
|
4426
4425
|
}
|
|
4427
|
-
|
|
4426
|
+
Gt(Ft({
|
|
4428
4427
|
conversation: n,
|
|
4429
4428
|
kind: o,
|
|
4430
4429
|
text: e.caption?.trim() ?? "",
|
|
@@ -4442,34 +4441,34 @@ function cc({ environment: e }) {
|
|
|
4442
4441
|
let t = new H.MediaMessage(n.targetId, e.file, o, kc(n));
|
|
4443
4442
|
t.setMuid?.(i), Object.keys(a).length > 0 && t.setMetadata?.(a), r && t.setParentMessageId?.(Number(r)), e.caption?.trim() && t.setCaption?.(e.caption.trim());
|
|
4444
4443
|
let s = await H.sendMediaMessage(t);
|
|
4445
|
-
|
|
4444
|
+
Tt(F(s, _.value?.uid)), _t(s), await bt(s), D.value = null;
|
|
4446
4445
|
} catch (t) {
|
|
4447
|
-
if (
|
|
4448
|
-
|
|
4446
|
+
if (Rt(t)) {
|
|
4447
|
+
Kt("queued", i), await Ut(n, e, a, r, i), D.value = null;
|
|
4449
4448
|
return;
|
|
4450
4449
|
}
|
|
4451
|
-
throw
|
|
4450
|
+
throw Kt("failed", i), g.value = Z(t, "Unable to send the attachment."), t;
|
|
4452
4451
|
} finally {
|
|
4453
4452
|
u.value = !1;
|
|
4454
4453
|
}
|
|
4455
4454
|
}
|
|
4456
|
-
async function
|
|
4455
|
+
async function W(e, t) {
|
|
4457
4456
|
if (u.value) return;
|
|
4458
4457
|
let n = I.value;
|
|
4459
4458
|
if (!n) return;
|
|
4460
4459
|
let r = e.question.trim(), i = e.options.map((e) => e.trim()).filter(Boolean);
|
|
4461
4460
|
if (!r || i.length < 2) return;
|
|
4462
|
-
let a = E.value?.id, o = crypto.randomUUID(), s = Dc(
|
|
4461
|
+
let a = E.value?.id, o = crypto.randomUUID(), s = Dc(It(D.value, t), o);
|
|
4463
4462
|
u.value = !0, g.value = null;
|
|
4464
4463
|
try {
|
|
4465
4464
|
if (m.value) {
|
|
4466
|
-
|
|
4465
|
+
Bt(n, {
|
|
4467
4466
|
question: r,
|
|
4468
4467
|
options: i
|
|
4469
4468
|
}, s, a, o), D.value = null;
|
|
4470
4469
|
return;
|
|
4471
4470
|
}
|
|
4472
|
-
|
|
4471
|
+
Gt(Ft({
|
|
4473
4472
|
conversation: n,
|
|
4474
4473
|
kind: "poll",
|
|
4475
4474
|
text: `Poll: ${r}`,
|
|
@@ -4490,37 +4489,37 @@ function cc({ environment: e }) {
|
|
|
4490
4489
|
};
|
|
4491
4490
|
a && (e.parentMessageId = Number(a)), Object.keys(s).length > 0 && (e.metadata = s);
|
|
4492
4491
|
let t = await H.callExtension("polls", "POST", "v2/create", e), c = t?.message ?? t?.custom_message ?? t?.data?.message ?? null;
|
|
4493
|
-
c ? (
|
|
4492
|
+
c ? (qt(o), Tt(F(c, _.value?.uid)), _t(c), await bt(c)) : (qt(o), await wt()), D.value = null;
|
|
4494
4493
|
} catch (e) {
|
|
4495
|
-
if (
|
|
4496
|
-
|
|
4494
|
+
if (Rt(e)) {
|
|
4495
|
+
Kt("queued", o), Bt(n, {
|
|
4497
4496
|
question: r,
|
|
4498
4497
|
options: i
|
|
4499
4498
|
}, s, a, o), D.value = null;
|
|
4500
4499
|
return;
|
|
4501
4500
|
}
|
|
4502
|
-
throw
|
|
4501
|
+
throw Kt("failed", o), g.value = Z(e, "Unable to send the poll."), e;
|
|
4503
4502
|
} finally {
|
|
4504
4503
|
u.value = !1;
|
|
4505
4504
|
}
|
|
4506
4505
|
}
|
|
4507
|
-
async function
|
|
4506
|
+
async function ze(e, t) {
|
|
4508
4507
|
let n = e.poll?.id ?? e.id, r = _.value?.uid;
|
|
4509
4508
|
if (!n || !t || m.value) return;
|
|
4510
|
-
let i =
|
|
4509
|
+
let i = Dt(e.id, e.parentMessageId) ?? e;
|
|
4511
4510
|
if (i.poll && !i.poll.options.some((e) => e.id === t && e.voters.includes(r ?? ""))) {
|
|
4512
|
-
g.value = null, r &&
|
|
4511
|
+
g.value = null, r && Tt(Be(i, t, r));
|
|
4513
4512
|
try {
|
|
4514
4513
|
await H.callExtension("polls", "POST", "v2/vote", {
|
|
4515
4514
|
id: n,
|
|
4516
4515
|
vote: t
|
|
4517
4516
|
});
|
|
4518
4517
|
} catch (e) {
|
|
4519
|
-
throw
|
|
4518
|
+
throw Tt(i), g.value = Z(e, "Unable to cast the vote."), e;
|
|
4520
4519
|
}
|
|
4521
4520
|
}
|
|
4522
4521
|
}
|
|
4523
|
-
function
|
|
4522
|
+
function Be(e, t, n) {
|
|
4524
4523
|
if (!e.poll) return e;
|
|
4525
4524
|
let r = e.poll, i = r.allowsMultipleAnswers, a = r.options.filter((e) => e.voters.includes(n)).map((e) => e.id), o = !i && a.length > 0, s = r.options.map((e) => o && e.voters.includes(n) && e.id !== t ? {
|
|
4526
4525
|
...e,
|
|
@@ -4540,29 +4539,29 @@ function cc({ environment: e }) {
|
|
|
4540
4539
|
}
|
|
4541
4540
|
};
|
|
4542
4541
|
}
|
|
4543
|
-
async function
|
|
4542
|
+
async function Ve(e, t) {
|
|
4544
4543
|
g.value = null;
|
|
4545
|
-
let n =
|
|
4546
|
-
|
|
4544
|
+
let n = Dt(e.id, e.parentMessageId) ?? e, r = n.reactions.find((e) => e.emoji === t && e.reactedByMe);
|
|
4545
|
+
Tt(Ot(n, t));
|
|
4547
4546
|
try {
|
|
4548
|
-
|
|
4547
|
+
Tt(F(r ? await H.removeReaction(Number(e.id), t) : await H.addReaction(Number(e.id), t), _.value?.uid));
|
|
4549
4548
|
} catch (e) {
|
|
4550
|
-
throw
|
|
4549
|
+
throw Tt(n), g.value = Z(e, "Unable to update the reaction."), e;
|
|
4551
4550
|
}
|
|
4552
4551
|
}
|
|
4553
|
-
async function
|
|
4552
|
+
async function Ue(e) {
|
|
4554
4553
|
if (g.value = null, e.deliveryState === "queued" || e.deliveryState === "failed") {
|
|
4555
|
-
|
|
4554
|
+
jt(e);
|
|
4556
4555
|
return;
|
|
4557
4556
|
}
|
|
4558
4557
|
if (!m.value) try {
|
|
4559
4558
|
let t = F(await H.deleteMessage(String(e.id)), _.value?.uid);
|
|
4560
|
-
|
|
4559
|
+
jt(t), Mt(t);
|
|
4561
4560
|
} catch (e) {
|
|
4562
4561
|
throw g.value = Z(e, "Unable to delete the message."), e;
|
|
4563
4562
|
}
|
|
4564
4563
|
}
|
|
4565
|
-
async function
|
|
4564
|
+
async function We(e) {
|
|
4566
4565
|
let t = e.source?.getText?.() ?? e.text;
|
|
4567
4566
|
if (Hs(t)) {
|
|
4568
4567
|
g.value = null;
|
|
@@ -4573,20 +4572,20 @@ function cc({ environment: e }) {
|
|
|
4573
4572
|
languages: typeof navigator < "u" ? navigator.languages : ["en"]
|
|
4574
4573
|
})).translations?.[0]?.message_translated?.trim();
|
|
4575
4574
|
if (!n) return;
|
|
4576
|
-
|
|
4575
|
+
Et({
|
|
4577
4576
|
...e,
|
|
4578
4577
|
translatedText: n,
|
|
4579
4578
|
metadata: {
|
|
4580
4579
|
...e.metadata ?? {},
|
|
4581
4580
|
translated_message: n
|
|
4582
4581
|
}
|
|
4583
|
-
}),
|
|
4582
|
+
}), At();
|
|
4584
4583
|
} catch (e) {
|
|
4585
4584
|
throw g.value = Z(e, "Unable to translate the message."), e;
|
|
4586
4585
|
}
|
|
4587
4586
|
}
|
|
4588
4587
|
}
|
|
4589
|
-
async function
|
|
4588
|
+
async function Ge(e) {
|
|
4590
4589
|
let t = e ?? I.value?.targetId, n = _.value?.uid, r = ++fe;
|
|
4591
4590
|
if (!t || !n) {
|
|
4592
4591
|
r === fe && (x.value = []);
|
|
@@ -4610,12 +4609,12 @@ function cc({ environment: e }) {
|
|
|
4610
4609
|
}
|
|
4611
4610
|
}
|
|
4612
4611
|
}
|
|
4613
|
-
async function
|
|
4612
|
+
async function Ke(e, t) {
|
|
4614
4613
|
let n = I.value;
|
|
4615
4614
|
if (n) {
|
|
4616
4615
|
d.value = !0, g.value = null;
|
|
4617
4616
|
try {
|
|
4618
|
-
e.file ? await Mc(n, e, t) : await jc(n, e, t), await
|
|
4617
|
+
e.file ? await Mc(n, e, t) : await jc(n, e, t), await Ge(n.targetId);
|
|
4619
4618
|
} catch (e) {
|
|
4620
4619
|
throw g.value = Z(e, "Unable to schedule the message."), e;
|
|
4621
4620
|
} finally {
|
|
@@ -4623,16 +4622,16 @@ function cc({ environment: e }) {
|
|
|
4623
4622
|
}
|
|
4624
4623
|
}
|
|
4625
4624
|
}
|
|
4626
|
-
async function
|
|
4625
|
+
async function Ye(e) {
|
|
4627
4626
|
if (g.value = null, !e.scheduled) return;
|
|
4628
4627
|
let t = e.scheduled.originalChatUid;
|
|
4629
4628
|
try {
|
|
4630
|
-
await H.deleteMessage(String(e.id)), x.value = x.value.filter((t) => t.id !== e.id), await
|
|
4629
|
+
await H.deleteMessage(String(e.id)), x.value = x.value.filter((t) => t.id !== e.id), await Ge(t);
|
|
4631
4630
|
} catch (e) {
|
|
4632
4631
|
throw g.value = Z(e, "Unable to remove the scheduled message."), e;
|
|
4633
4632
|
}
|
|
4634
4633
|
}
|
|
4635
|
-
async function
|
|
4634
|
+
async function Xe(e, t) {
|
|
4636
4635
|
g.value = null;
|
|
4637
4636
|
let n = _.value?.uid;
|
|
4638
4637
|
if (!n || !e.scheduled?.muid || e.kind === "poll") return;
|
|
@@ -4647,14 +4646,14 @@ function cc({ environment: e }) {
|
|
|
4647
4646
|
let i = e.source?.getAttachment?.()?.getFileUrl?.() ?? e.source?.getAttachment?.()?.getUrl?.() ?? e.attachments[0]?.url ?? "";
|
|
4648
4647
|
t = new H.MediaMessage(n, i, e.source?.getType?.() ?? e.type ?? e.kind, H.RECEIVER_TYPE.GROUP), t.setCaption(r);
|
|
4649
4648
|
}
|
|
4650
|
-
Object.keys(i).length > 0 && t.setMetadata(i), t.setId(Number(e.id)), await H.editMessage(t), await
|
|
4649
|
+
Object.keys(i).length > 0 && t.setMetadata(i), t.setId(Number(e.id)), await H.editMessage(t), await Ge(e.scheduled.originalChatUid);
|
|
4651
4650
|
} catch (e) {
|
|
4652
4651
|
throw g.value = Z(e, "Unable to edit the scheduled message."), e;
|
|
4653
4652
|
} finally {
|
|
4654
4653
|
d.value = !1;
|
|
4655
4654
|
}
|
|
4656
4655
|
}
|
|
4657
|
-
async function
|
|
4656
|
+
async function Ze(e) {
|
|
4658
4657
|
d.value = !0, g.value = null;
|
|
4659
4658
|
try {
|
|
4660
4659
|
let t = Ac(), n = await fetch(`${G().chatApiBaseUrl}/chats/rescheduleMessage`, {
|
|
@@ -4671,21 +4670,21 @@ function cc({ environment: e }) {
|
|
|
4671
4670
|
})
|
|
4672
4671
|
});
|
|
4673
4672
|
if (!n.ok) throw Error(`Reschedule failed with status ${n.status}.`);
|
|
4674
|
-
await
|
|
4673
|
+
await Ge(e.originalChatUid);
|
|
4675
4674
|
} catch (e) {
|
|
4676
4675
|
throw g.value = Z(e, "Unable to reschedule the message."), e;
|
|
4677
4676
|
} finally {
|
|
4678
4677
|
d.value = !1;
|
|
4679
4678
|
}
|
|
4680
4679
|
}
|
|
4681
|
-
function
|
|
4680
|
+
function $e(e) {
|
|
4682
4681
|
let t = new H.MessagesRequestBuilder().setLimit(50).hideReplies(!0).hideDeletedMessages(!0);
|
|
4683
4682
|
return e.type === "group" ? t.setGUID(e.targetId) : t.setUID(e.targetId), t.build();
|
|
4684
4683
|
}
|
|
4685
|
-
function
|
|
4684
|
+
function et(e) {
|
|
4686
4685
|
return new H.MessagesRequestBuilder().setLimit(50).setParentMessageId(Number(e)).hideDeletedMessages(!0).build();
|
|
4687
4686
|
}
|
|
4688
|
-
async function
|
|
4687
|
+
async function tt(e) {
|
|
4689
4688
|
if (!e.isOwn || e.receipts.readAt) return e;
|
|
4690
4689
|
let t = `bcc-chat:${G().appId}:message_${e.id}_receiptStatus`;
|
|
4691
4690
|
try {
|
|
@@ -4695,7 +4694,7 @@ function cc({ environment: e }) {
|
|
|
4695
4694
|
if (!Number.isNaN(r.getTime()) && !Number.isNaN(i.getTime())) return e.receipts.readAt = r, e.receipts.deliveredAt = i, e;
|
|
4696
4695
|
}
|
|
4697
4696
|
} catch {}
|
|
4698
|
-
let n = await
|
|
4697
|
+
let n = await St(e);
|
|
4699
4698
|
for (let t of n) t.kind === "read" && t.timestamp && (!e.receipts.readAt || t.timestamp > e.receipts.readAt) && (e.receipts.readAt = t.timestamp), t.kind === "delivered" && t.timestamp && (!e.receipts.deliveredAt || t.timestamp > e.receipts.deliveredAt) && (e.receipts.deliveredAt = t.timestamp);
|
|
4700
4699
|
if (e.receipts.readAt) try {
|
|
4701
4700
|
localStorage.setItem(t, JSON.stringify({
|
|
@@ -4705,7 +4704,7 @@ function cc({ environment: e }) {
|
|
|
4705
4704
|
} catch {}
|
|
4706
4705
|
return e;
|
|
4707
4706
|
}
|
|
4708
|
-
async function
|
|
4707
|
+
async function nt(e) {
|
|
4709
4708
|
try {
|
|
4710
4709
|
return await e.fetchPrevious();
|
|
4711
4710
|
} catch (e) {
|
|
@@ -4713,32 +4712,37 @@ function cc({ environment: e }) {
|
|
|
4713
4712
|
throw e;
|
|
4714
4713
|
}
|
|
4715
4714
|
}
|
|
4716
|
-
async function
|
|
4715
|
+
async function rt(e) {
|
|
4717
4716
|
let t = I.value;
|
|
4718
4717
|
if (!t || m.value) return y.value = [], S.value = !1, !1;
|
|
4719
4718
|
if ((e?.reset || ue?.conversationId !== t.id) && (ue = {
|
|
4720
4719
|
conversationId: t.id,
|
|
4721
|
-
request:
|
|
4720
|
+
request: $e(t)
|
|
4722
4721
|
}, S.value = !0), !ue) return !1;
|
|
4723
|
-
let n = await
|
|
4722
|
+
let n = await nt(ue.request);
|
|
4723
|
+
e?.reset && n.length === 0 && !m.value && !V && t.lastMessageAt && (se = !0, await we(), ue = {
|
|
4724
|
+
conversationId: t.id,
|
|
4725
|
+
request: $e(t)
|
|
4726
|
+
}, n = await nt(ue.request));
|
|
4727
|
+
let r = await Promise.all(n.map((e) => F(e, _.value?.uid)).filter(Tc).sort(xc).map(tt));
|
|
4724
4728
|
y.value = e?.reset ? Cc(y.value.filter((e) => e.conversationId === t.id && wc(e)), r) : Cc(y.value, r), S.value = n.length === 50, U?.setMessages(t.id, y.value);
|
|
4725
4729
|
let i = n[n.length - 1];
|
|
4726
|
-
return i && (await
|
|
4730
|
+
return i && (await xt(i), await bt(i)), n.length > 0;
|
|
4727
4731
|
}
|
|
4728
|
-
async function
|
|
4732
|
+
async function it() {
|
|
4729
4733
|
N();
|
|
4730
4734
|
let e = I.value;
|
|
4731
4735
|
if (!e) {
|
|
4732
4736
|
y.value = [], S.value = !1, ue = null;
|
|
4733
4737
|
return;
|
|
4734
4738
|
}
|
|
4735
|
-
let t =
|
|
4739
|
+
let t = De(e.id);
|
|
4736
4740
|
if (a.value = !0, m.value) {
|
|
4737
4741
|
S.value = !1, ue = null, a.value = !1;
|
|
4738
4742
|
return;
|
|
4739
4743
|
}
|
|
4740
4744
|
try {
|
|
4741
|
-
await
|
|
4745
|
+
await rt({ reset: !0 }), v.value = v.value.map((t) => t.id === e.id ? {
|
|
4742
4746
|
...t,
|
|
4743
4747
|
lastMessage: y.value.at(-1) ?? null,
|
|
4744
4748
|
unreadCount: 0
|
|
@@ -4754,25 +4758,25 @@ function cc({ environment: e }) {
|
|
|
4754
4758
|
a.value = !1;
|
|
4755
4759
|
}
|
|
4756
4760
|
}
|
|
4757
|
-
async function
|
|
4761
|
+
async function at(e) {
|
|
4758
4762
|
let t = E.value?.id;
|
|
4759
4763
|
if (!t) return b.value = [], C.value = !1, !1;
|
|
4760
4764
|
if ((e?.reset || de?.parentMessageId !== t) && (de = {
|
|
4761
4765
|
parentMessageId: t,
|
|
4762
|
-
request:
|
|
4766
|
+
request: et(t)
|
|
4763
4767
|
}, C.value = !0), !de) return !1;
|
|
4764
|
-
let n = await de.request.fetchPrevious(), r = await Promise.all(n.map((e) => F(e, _.value?.uid)).filter(Tc).sort(xc).map(
|
|
4768
|
+
let n = await de.request.fetchPrevious(), r = await Promise.all(n.map((e) => F(e, _.value?.uid)).filter(Tc).sort(xc).map(tt));
|
|
4765
4769
|
b.value = e?.reset ? Cc(b.value.filter((e) => e.parentMessageId === t && wc(e)), r) : Cc(b.value, r), C.value = n.length === 50, U?.setThreadMessages(t, b.value);
|
|
4766
4770
|
let i = n[n.length - 1];
|
|
4767
|
-
return i && (await
|
|
4771
|
+
return i && (await xt(i), await bt(i)), n.length > 0;
|
|
4768
4772
|
}
|
|
4769
|
-
async function
|
|
4773
|
+
async function ot(e) {
|
|
4770
4774
|
if (o.value = !0, m.value) {
|
|
4771
4775
|
b.value = (U?.getThreadMessages(e) ?? []).sort(xc), C.value = !1, de = null, o.value = !1;
|
|
4772
4776
|
return;
|
|
4773
4777
|
}
|
|
4774
4778
|
try {
|
|
4775
|
-
await
|
|
4779
|
+
await at({ reset: !0 });
|
|
4776
4780
|
} catch (t) {
|
|
4777
4781
|
let n = U?.getThreadMessages(e) ?? [];
|
|
4778
4782
|
if (n.length > 0) {
|
|
@@ -4784,29 +4788,29 @@ function cc({ environment: e }) {
|
|
|
4784
4788
|
o.value = !1;
|
|
4785
4789
|
}
|
|
4786
4790
|
}
|
|
4787
|
-
async function
|
|
4791
|
+
async function st() {
|
|
4788
4792
|
if (a.value || s.value || !S.value) return !1;
|
|
4789
4793
|
s.value = !0, g.value = null;
|
|
4790
4794
|
try {
|
|
4791
|
-
return await
|
|
4795
|
+
return await rt();
|
|
4792
4796
|
} catch (e) {
|
|
4793
4797
|
throw g.value = Z(e, "Unable to load messages."), e;
|
|
4794
4798
|
} finally {
|
|
4795
4799
|
s.value = !1;
|
|
4796
4800
|
}
|
|
4797
4801
|
}
|
|
4798
|
-
async function
|
|
4802
|
+
async function ct() {
|
|
4799
4803
|
if (o.value || c.value || !C.value) return !1;
|
|
4800
4804
|
c.value = !0, g.value = null;
|
|
4801
4805
|
try {
|
|
4802
|
-
return await
|
|
4806
|
+
return await at();
|
|
4803
4807
|
} catch (e) {
|
|
4804
4808
|
throw g.value = Z(e, "Unable to load thread."), e;
|
|
4805
4809
|
} finally {
|
|
4806
4810
|
c.value = !1;
|
|
4807
4811
|
}
|
|
4808
4812
|
}
|
|
4809
|
-
async function
|
|
4813
|
+
async function ut(e) {
|
|
4810
4814
|
let t = e.trim();
|
|
4811
4815
|
if (!t) return !1;
|
|
4812
4816
|
let n = () => y.value.some((e) => e.id === t) || b.value.some((e) => e.id === t) || E.value?.id === t;
|
|
@@ -4814,92 +4818,92 @@ function cc({ environment: e }) {
|
|
|
4814
4818
|
let r = 0;
|
|
4815
4819
|
for (; C.value && E.value && r < 100;) {
|
|
4816
4820
|
r += 1;
|
|
4817
|
-
let e = await
|
|
4821
|
+
let e = await ct();
|
|
4818
4822
|
if (n()) return !0;
|
|
4819
4823
|
if (!e) break;
|
|
4820
4824
|
}
|
|
4821
4825
|
for (; S.value && I.value && r < 100;) {
|
|
4822
4826
|
r += 1;
|
|
4823
|
-
let e = await
|
|
4827
|
+
let e = await st();
|
|
4824
4828
|
if (n()) return !0;
|
|
4825
4829
|
if (!e) break;
|
|
4826
4830
|
}
|
|
4827
4831
|
return n();
|
|
4828
4832
|
}
|
|
4829
|
-
async function
|
|
4830
|
-
let e = await H.
|
|
4833
|
+
async function ft() {
|
|
4834
|
+
let e = await H.getLoggedInUser();
|
|
4831
4835
|
_.value = e ? hc(e) : null, h.value = !!e;
|
|
4832
4836
|
}
|
|
4833
|
-
function
|
|
4837
|
+
function pt() {
|
|
4834
4838
|
R ||= (H.addConnectionListener(te, new H.ConnectionListener({
|
|
4835
4839
|
onConnected: () => {
|
|
4836
4840
|
if (p.value = !0, oe = 0, ye(), se) {
|
|
4837
|
-
|
|
4841
|
+
Te();
|
|
4838
4842
|
return;
|
|
4839
4843
|
}
|
|
4840
|
-
|
|
4844
|
+
Jt();
|
|
4841
4845
|
},
|
|
4842
4846
|
onDisconnected: () => {
|
|
4843
|
-
p.value = !1, !m.value && h.value
|
|
4847
|
+
p.value = !1, !m.value && !V && (h.value || Se()) && (se = !0, Ce(!0));
|
|
4844
4848
|
}
|
|
4845
4849
|
})), H.addMessageListener(L, new H.MessageListener({
|
|
4846
4850
|
onTextMessageReceived: (e) => {
|
|
4847
|
-
|
|
4851
|
+
mt(e);
|
|
4848
4852
|
},
|
|
4849
4853
|
onMediaMessageReceived: (e) => {
|
|
4850
|
-
|
|
4854
|
+
mt(e);
|
|
4851
4855
|
},
|
|
4852
4856
|
onCustomMessageReceived: (e) => {
|
|
4853
|
-
|
|
4857
|
+
mt(e);
|
|
4854
4858
|
},
|
|
4855
4859
|
onMessagesDelivered: () => {
|
|
4856
|
-
xe() ||
|
|
4860
|
+
xe() || wt({ includeThread: !1 });
|
|
4857
4861
|
},
|
|
4858
4862
|
onMessagesRead: () => {
|
|
4859
|
-
xe() ||
|
|
4863
|
+
xe() || wt({ includeThread: !1 });
|
|
4860
4864
|
},
|
|
4861
4865
|
onMessageEdited: (e) => {
|
|
4862
4866
|
let t = F(e, _.value?.uid);
|
|
4863
|
-
Tc(t) && (
|
|
4867
|
+
Tc(t) && (K(t), _t(e));
|
|
4864
4868
|
},
|
|
4865
4869
|
onMessageDeleted: (e) => {
|
|
4866
4870
|
let t = F(e, _.value?.uid);
|
|
4867
|
-
t.parentMessageId ?
|
|
4871
|
+
t.parentMessageId ? jt(t) : (jt(t), Mt(t)), At();
|
|
4868
4872
|
},
|
|
4869
4873
|
onMessageReactionAdded: () => {
|
|
4870
|
-
|
|
4874
|
+
wt();
|
|
4871
4875
|
},
|
|
4872
4876
|
onMessageReactionRemoved: () => {
|
|
4873
|
-
|
|
4877
|
+
wt();
|
|
4874
4878
|
},
|
|
4875
4879
|
onMessagesDeliveredToAll: () => {
|
|
4876
|
-
xe() ||
|
|
4880
|
+
xe() || wt({ includeThread: !1 });
|
|
4877
4881
|
},
|
|
4878
4882
|
onMessagesReadByAll: () => {
|
|
4879
|
-
xe() ||
|
|
4883
|
+
xe() || wt({ includeThread: !1 });
|
|
4880
4884
|
}
|
|
4881
4885
|
})), !0);
|
|
4882
4886
|
}
|
|
4883
|
-
async function
|
|
4887
|
+
async function mt(e) {
|
|
4884
4888
|
let t = F(e, _.value?.uid);
|
|
4885
4889
|
if (Tc(t)) {
|
|
4886
|
-
if (
|
|
4887
|
-
|
|
4890
|
+
if (_t(e), await xt(e), t.parentMessageId) {
|
|
4891
|
+
yt(t), kt(t.parentMessageId), At();
|
|
4888
4892
|
return;
|
|
4889
4893
|
}
|
|
4890
|
-
t.conversationId === T.value && (
|
|
4894
|
+
t.conversationId === T.value && (K(t), At(), await bt(e));
|
|
4891
4895
|
}
|
|
4892
4896
|
}
|
|
4893
|
-
async function
|
|
4897
|
+
async function ht(e) {
|
|
4894
4898
|
return await Promise.all(e.map(async (e) => {
|
|
4895
|
-
let t = await
|
|
4899
|
+
let t = await gt(e.targetId);
|
|
4896
4900
|
return {
|
|
4897
4901
|
...e,
|
|
4898
4902
|
muteSettings: t ? new Date(t) : null
|
|
4899
4903
|
};
|
|
4900
4904
|
}));
|
|
4901
4905
|
}
|
|
4902
|
-
async function
|
|
4906
|
+
async function gt(e) {
|
|
4903
4907
|
let t = U?.getParticipantSettings(e), n = t?.lastUpdated ? Date.now() - t.lastUpdated > 1440 * 60 * 1e3 : !0;
|
|
4904
4908
|
if (t && (m.value || !n)) return t.mutedUntil;
|
|
4905
4909
|
if (m.value || !h.value) return t?.mutedUntil ?? null;
|
|
@@ -4926,12 +4930,12 @@ function cc({ environment: e }) {
|
|
|
4926
4930
|
return t?.mutedUntil ?? null;
|
|
4927
4931
|
}
|
|
4928
4932
|
}
|
|
4929
|
-
function
|
|
4933
|
+
function _t(e) {
|
|
4930
4934
|
let t = F(e, _.value?.uid);
|
|
4931
4935
|
if (!Tc(t) || t.isDeleted) return;
|
|
4932
4936
|
let n = e.getConversationId(), r = v.value.find((e) => e.id === n);
|
|
4933
4937
|
if (!r) {
|
|
4934
|
-
|
|
4938
|
+
Ae();
|
|
4935
4939
|
return;
|
|
4936
4940
|
}
|
|
4937
4941
|
let i = {
|
|
@@ -4943,33 +4947,33 @@ function cc({ environment: e }) {
|
|
|
4943
4947
|
};
|
|
4944
4948
|
v.value = bc(v.value.map((e) => e.id === n ? i : e)), U?.setConversations(v.value);
|
|
4945
4949
|
}
|
|
4946
|
-
function
|
|
4950
|
+
function K(e) {
|
|
4947
4951
|
y.value = Sc(y.value, e), T.value && U?.setMessages(T.value, y.value);
|
|
4948
4952
|
}
|
|
4949
|
-
function
|
|
4953
|
+
function yt(e) {
|
|
4950
4954
|
e.parentMessageId === E.value?.id && (b.value = Sc(b.value, e), e.parentMessageId && U?.setThreadMessages(e.parentMessageId, b.value));
|
|
4951
4955
|
}
|
|
4952
|
-
async function
|
|
4956
|
+
async function bt(e) {
|
|
4953
4957
|
if (m.value) return;
|
|
4954
4958
|
let t = e.getSender?.()?.getUid?.();
|
|
4955
4959
|
!t || t === _.value?.uid || e.getReadByMeAt?.() || (be(), await H.markAsRead(e));
|
|
4956
4960
|
}
|
|
4957
|
-
async function
|
|
4961
|
+
async function xt(e) {
|
|
4958
4962
|
if (m.value) return;
|
|
4959
4963
|
let t = e.getSender?.()?.getUid?.();
|
|
4960
4964
|
!t || t === _.value?.uid || e.getDeliveredToMeAt?.() || (be(), await H.markAsDelivered(e));
|
|
4961
4965
|
}
|
|
4962
|
-
async function
|
|
4966
|
+
async function St(e) {
|
|
4963
4967
|
return m.value ? [] : pc(await H.getMessageReceipts(String(e.id)));
|
|
4964
4968
|
}
|
|
4965
|
-
function
|
|
4969
|
+
function Ct() {
|
|
4966
4970
|
r.value = !1, i.value = !1, a.value = !1, o.value = !1, s.value = !1, c.value = !1, l.value = !1, u.value = !1, d.value = !1, f.value = !1, p.value = !1, ye(), oe = 0, se = !1, V = !1, h.value = !1, _.value = null, v.value = [], y.value = [], b.value = [], x.value = [], E.value = null, D.value = null, O.value = null, k.value = [], T.value = null, S.value = !1, C.value = !1, ue = null, de = null, le.clear();
|
|
4967
4971
|
}
|
|
4968
|
-
async function
|
|
4972
|
+
async function wt(e) {
|
|
4969
4973
|
if (ie) return ie;
|
|
4970
4974
|
let t = e?.includeThread ?? !0;
|
|
4971
4975
|
ie = (async () => {
|
|
4972
|
-
I.value && await
|
|
4976
|
+
I.value && await it(), t && E.value && await ot(E.value.id);
|
|
4973
4977
|
})();
|
|
4974
4978
|
try {
|
|
4975
4979
|
await ie;
|
|
@@ -4977,20 +4981,20 @@ function cc({ environment: e }) {
|
|
|
4977
4981
|
ie = null;
|
|
4978
4982
|
}
|
|
4979
4983
|
}
|
|
4980
|
-
function wt(e) {
|
|
4981
|
-
Tt(e), e.parentMessageId && Ot(e.parentMessageId, e.replyCount), kt();
|
|
4982
|
-
}
|
|
4983
4984
|
function Tt(e) {
|
|
4985
|
+
Et(e), e.parentMessageId && kt(e.parentMessageId, e.replyCount), At();
|
|
4986
|
+
}
|
|
4987
|
+
function Et(e) {
|
|
4984
4988
|
if (e.parentMessageId) {
|
|
4985
4989
|
E.value?.id === e.parentMessageId && (b.value = Sc(b.value, e));
|
|
4986
4990
|
return;
|
|
4987
4991
|
}
|
|
4988
4992
|
y.value = Sc(y.value, e), E.value?.id === e.id && (E.value = e);
|
|
4989
4993
|
}
|
|
4990
|
-
function
|
|
4994
|
+
function Dt(e, t) {
|
|
4991
4995
|
return t ? b.value.find((t) => t.id === e) ?? null : E.value?.id === e ? E.value : y.value.find((t) => t.id === e) ?? null;
|
|
4992
4996
|
}
|
|
4993
|
-
function
|
|
4997
|
+
function Ot(e, t) {
|
|
4994
4998
|
let n = e.reactions.find((e) => e.emoji === t);
|
|
4995
4999
|
return n ? n.reactedByMe && n.count === 1 ? {
|
|
4996
5000
|
...e,
|
|
@@ -5011,7 +5015,7 @@ function cc({ environment: e }) {
|
|
|
5011
5015
|
}]
|
|
5012
5016
|
};
|
|
5013
5017
|
}
|
|
5014
|
-
function
|
|
5018
|
+
function kt(e, t) {
|
|
5015
5019
|
let n = y.value.find((t) => t.id === e);
|
|
5016
5020
|
if (!n) return;
|
|
5017
5021
|
let r = {
|
|
@@ -5020,18 +5024,18 @@ function cc({ environment: e }) {
|
|
|
5020
5024
|
};
|
|
5021
5025
|
y.value = Sc(y.value, r), E.value?.id === e && (E.value = r);
|
|
5022
5026
|
}
|
|
5023
|
-
function
|
|
5027
|
+
function At() {
|
|
5024
5028
|
T.value && U?.setMessages(T.value, y.value), E.value && U?.setThreadMessages(E.value.id, b.value);
|
|
5025
5029
|
}
|
|
5026
|
-
function
|
|
5030
|
+
function jt(e) {
|
|
5027
5031
|
if (e.parentMessageId ? (b.value = b.value.filter((t) => t.id !== e.id), U?.setThreadMessages(e.parentMessageId, b.value)) : (y.value = y.value.filter((t) => t.id !== e.id), T.value && U?.setMessages(T.value, y.value)), e.muid) {
|
|
5028
5032
|
k.value = k.value.filter((t) => t.muid !== e.muid);
|
|
5029
5033
|
let t = U?.getQueue().filter((t) => t.muid === e.muid) ?? [];
|
|
5030
5034
|
for (let e of t) U?.dequeue(e.id), ce.delete(e.id), e.kind === "attachment" && U?.deleteQueuedAttachment(e.id);
|
|
5031
5035
|
}
|
|
5032
|
-
e.parentMessageId ||
|
|
5036
|
+
e.parentMessageId || Nt(e.conversationId);
|
|
5033
5037
|
}
|
|
5034
|
-
function
|
|
5038
|
+
function Mt(e) {
|
|
5035
5039
|
if (e.parentMessageId) return;
|
|
5036
5040
|
let t = e.conversationId, n = v.value.find((e) => e.id === t);
|
|
5037
5041
|
if (!n) return;
|
|
@@ -5056,7 +5060,7 @@ function cc({ environment: e }) {
|
|
|
5056
5060
|
lastMessageAt: void 0
|
|
5057
5061
|
} : e : e)), U?.setConversations(v.value);
|
|
5058
5062
|
}
|
|
5059
|
-
function
|
|
5063
|
+
function Nt(e, t) {
|
|
5060
5064
|
let n = y.value.length > 0 ? y.value[y.value.length - 1] : null, r = t ?? n;
|
|
5061
5065
|
v.value = bc(v.value.map((t) => t.id === e ? {
|
|
5062
5066
|
...t,
|
|
@@ -5065,7 +5069,7 @@ function cc({ environment: e }) {
|
|
|
5065
5069
|
lastMessage: r
|
|
5066
5070
|
} : t)), U?.setConversations(v.value);
|
|
5067
5071
|
}
|
|
5068
|
-
function
|
|
5072
|
+
function Pt(e) {
|
|
5069
5073
|
v.value = bc(v.value.map((t) => t.id === e.conversationId ? {
|
|
5070
5074
|
...t,
|
|
5071
5075
|
subtitle: Oc(e),
|
|
@@ -5074,8 +5078,8 @@ function cc({ environment: e }) {
|
|
|
5074
5078
|
unreadCount: 0
|
|
5075
5079
|
} : t)), U?.setConversations(v.value);
|
|
5076
5080
|
}
|
|
5077
|
-
function
|
|
5078
|
-
let t = /* @__PURE__ */ new Date(), n =
|
|
5081
|
+
function Ft(e) {
|
|
5082
|
+
let t = /* @__PURE__ */ new Date(), n = Lt(e.metadata);
|
|
5079
5083
|
return {
|
|
5080
5084
|
id: `local-${e.muid}`,
|
|
5081
5085
|
muid: e.muid,
|
|
@@ -5114,11 +5118,11 @@ function cc({ environment: e }) {
|
|
|
5114
5118
|
source: null
|
|
5115
5119
|
};
|
|
5116
5120
|
}
|
|
5117
|
-
function
|
|
5121
|
+
function It(e, t) {
|
|
5118
5122
|
let n = {};
|
|
5119
5123
|
return t?.senderDisplayName?.trim() && (n.senderDisplayName = t.senderDisplayName.trim()), e ? (n.replyToMessageId = e.id, n.replyPreview = Js(e), n) : n;
|
|
5120
5124
|
}
|
|
5121
|
-
function
|
|
5125
|
+
function Lt(e) {
|
|
5122
5126
|
let t = e.replyPreview;
|
|
5123
5127
|
if (!t || typeof t != "object") return;
|
|
5124
5128
|
let n = t;
|
|
@@ -5129,13 +5133,13 @@ function cc({ environment: e }) {
|
|
|
5129
5133
|
kind: n.kind ?? "text"
|
|
5130
5134
|
};
|
|
5131
5135
|
}
|
|
5132
|
-
function
|
|
5136
|
+
function Rt(e) {
|
|
5133
5137
|
if (M() || m.value) return !0;
|
|
5134
5138
|
let t = Z(e, "").toLowerCase();
|
|
5135
5139
|
return t.includes("network") || t.includes("failed to fetch") || t.includes("socket") || t.includes("offline");
|
|
5136
5140
|
}
|
|
5137
|
-
function
|
|
5138
|
-
let a =
|
|
5141
|
+
function zt(e, t, n, r, i) {
|
|
5142
|
+
let a = Ft({
|
|
5139
5143
|
conversation: e,
|
|
5140
5144
|
kind: "text",
|
|
5141
5145
|
text: t,
|
|
@@ -5144,7 +5148,7 @@ function cc({ environment: e }) {
|
|
|
5144
5148
|
muid: i,
|
|
5145
5149
|
deliveryState: "queued"
|
|
5146
5150
|
});
|
|
5147
|
-
|
|
5151
|
+
Wt(a, {
|
|
5148
5152
|
id: a.id,
|
|
5149
5153
|
muid: i,
|
|
5150
5154
|
conversationId: e.id,
|
|
@@ -5157,9 +5161,9 @@ function cc({ environment: e }) {
|
|
|
5157
5161
|
createdAt: a.sentAt.toISOString()
|
|
5158
5162
|
});
|
|
5159
5163
|
}
|
|
5160
|
-
function
|
|
5161
|
-
if (
|
|
5162
|
-
let a =
|
|
5164
|
+
function Bt(e, t, n, r, i) {
|
|
5165
|
+
if (Ht(e, t, r)) return;
|
|
5166
|
+
let a = Ft({
|
|
5163
5167
|
conversation: e,
|
|
5164
5168
|
kind: "poll",
|
|
5165
5169
|
text: `Poll: ${t.question}`,
|
|
@@ -5169,7 +5173,7 @@ function cc({ environment: e }) {
|
|
|
5169
5173
|
muid: i,
|
|
5170
5174
|
deliveryState: "queued"
|
|
5171
5175
|
});
|
|
5172
|
-
|
|
5176
|
+
Wt(a, {
|
|
5173
5177
|
id: a.id,
|
|
5174
5178
|
muid: i,
|
|
5175
5179
|
conversationId: e.id,
|
|
@@ -5182,7 +5186,7 @@ function cc({ environment: e }) {
|
|
|
5182
5186
|
createdAt: a.sentAt.toISOString()
|
|
5183
5187
|
});
|
|
5184
5188
|
}
|
|
5185
|
-
function
|
|
5189
|
+
function Ht(e, t, n) {
|
|
5186
5190
|
let r = Date.now(), i = (e) => e.trim().toLowerCase(), a = (e) => e.map((e) => i(e)).filter(Boolean).join("\0"), o = i(t.question), s = a(t.options);
|
|
5187
5191
|
return k.value.some((t) => {
|
|
5188
5192
|
if (t.kind !== "poll" || !t.poll || t.conversationId !== e.id || t.targetId !== e.targetId || t.parentMessageId !== n) return !1;
|
|
@@ -5190,8 +5194,8 @@ function cc({ environment: e }) {
|
|
|
5190
5194
|
return Number.isNaN(c) || r - c > 5e3 ? !1 : i(t.poll.question) === o && a(t.poll.options) === s;
|
|
5191
5195
|
});
|
|
5192
5196
|
}
|
|
5193
|
-
async function
|
|
5194
|
-
let a = Nc(t.file), o =
|
|
5197
|
+
async function Ut(e, t, n, r, i) {
|
|
5198
|
+
let a = Nc(t.file), o = Ft({
|
|
5195
5199
|
conversation: e,
|
|
5196
5200
|
kind: a,
|
|
5197
5201
|
text: t.caption?.trim() ?? "",
|
|
@@ -5227,15 +5231,15 @@ function cc({ environment: e }) {
|
|
|
5227
5231
|
try {
|
|
5228
5232
|
await U?.storeQueuedAttachment(s.id, t.file);
|
|
5229
5233
|
} catch {}
|
|
5230
|
-
|
|
5234
|
+
Wt(o, s);
|
|
5231
5235
|
}
|
|
5232
|
-
function
|
|
5233
|
-
k.value = [...k.value, t], U?.enqueue(t),
|
|
5236
|
+
function Wt(e, t) {
|
|
5237
|
+
k.value = [...k.value, t], U?.enqueue(t), Gt(e);
|
|
5234
5238
|
}
|
|
5235
|
-
function
|
|
5236
|
-
e.parentMessageId ? (E.value?.id === e.parentMessageId && (b.value = Sc(b.value, e)),
|
|
5239
|
+
function Gt(e) {
|
|
5240
|
+
e.parentMessageId ? (E.value?.id === e.parentMessageId && (b.value = Sc(b.value, e)), kt(e.parentMessageId)) : y.value = Sc(y.value, e), Pt(e), At();
|
|
5237
5241
|
}
|
|
5238
|
-
function
|
|
5242
|
+
function Kt(e, t) {
|
|
5239
5243
|
let n = (n) => n.map((n) => {
|
|
5240
5244
|
let r = Ec(n);
|
|
5241
5245
|
return n.muid !== t && r !== t ? n : {
|
|
@@ -5243,18 +5247,18 @@ function cc({ environment: e }) {
|
|
|
5243
5247
|
deliveryState: e
|
|
5244
5248
|
};
|
|
5245
5249
|
});
|
|
5246
|
-
y.value = n(y.value), b.value = n(b.value),
|
|
5250
|
+
y.value = n(y.value), b.value = n(b.value), At();
|
|
5247
5251
|
}
|
|
5248
|
-
function
|
|
5252
|
+
function qt(e) {
|
|
5249
5253
|
if (!e) return;
|
|
5250
5254
|
let t = [...y.value, ...b.value].filter((t) => {
|
|
5251
5255
|
if (!t.id.startsWith("local-")) return !1;
|
|
5252
5256
|
let n = Ec(t);
|
|
5253
5257
|
return t.muid === e || n === e;
|
|
5254
5258
|
});
|
|
5255
|
-
for (let e of t)
|
|
5259
|
+
for (let e of t) jt(e);
|
|
5256
5260
|
}
|
|
5257
|
-
async function
|
|
5261
|
+
async function Jt() {
|
|
5258
5262
|
if (!(f.value || k.value.length === 0 || !h.value || m.value)) {
|
|
5259
5263
|
f.value = !0;
|
|
5260
5264
|
try {
|
|
@@ -5262,20 +5266,20 @@ function cc({ environment: e }) {
|
|
|
5262
5266
|
for (let t of e) if (!le.has(t.id)) {
|
|
5263
5267
|
le.add(t.id);
|
|
5264
5268
|
try {
|
|
5265
|
-
let e = await
|
|
5266
|
-
k.value = k.value.filter((e) => e.id !== t.id), U?.dequeue(t.id), ce.delete(t.id), t.kind === "attachment" && await U?.deleteQueuedAttachment(t.id),
|
|
5269
|
+
let e = await Yt(t);
|
|
5270
|
+
k.value = k.value.filter((e) => e.id !== t.id), U?.dequeue(t.id), ce.delete(t.id), t.kind === "attachment" && await U?.deleteQueuedAttachment(t.id), qt(t.muid), e ? Tt(F(e, _.value?.uid)) : await wt();
|
|
5267
5271
|
} finally {
|
|
5268
5272
|
le.delete(t.id);
|
|
5269
5273
|
}
|
|
5270
5274
|
}
|
|
5271
5275
|
} catch (e) {
|
|
5272
|
-
|
|
5276
|
+
Rt(e) || (g.value = Z(e, "Unable to sync queued messages."));
|
|
5273
5277
|
} finally {
|
|
5274
5278
|
f.value = !1;
|
|
5275
5279
|
}
|
|
5276
5280
|
}
|
|
5277
5281
|
}
|
|
5278
|
-
async function
|
|
5282
|
+
async function Yt(e) {
|
|
5279
5283
|
let t = e.receiverType === "group" ? H.RECEIVER_TYPE.GROUP : H.RECEIVER_TYPE.USER;
|
|
5280
5284
|
if (e.kind === "poll" && e.poll) {
|
|
5281
5285
|
let n = {
|
|
@@ -5327,33 +5331,33 @@ function cc({ environment: e }) {
|
|
|
5327
5331
|
replyToMessage: D,
|
|
5328
5332
|
editingMessage: O,
|
|
5329
5333
|
init: pe,
|
|
5330
|
-
connectRealtime:
|
|
5331
|
-
disconnectRealtime:
|
|
5334
|
+
connectRealtime: Oe,
|
|
5335
|
+
disconnectRealtime: ke,
|
|
5332
5336
|
login: me,
|
|
5333
5337
|
logout: he,
|
|
5334
|
-
fetchConversations:
|
|
5335
|
-
selectConversation:
|
|
5336
|
-
sendTextMessage:
|
|
5337
|
-
sendAttachmentMessage:
|
|
5338
|
-
sendPollMessage:
|
|
5339
|
-
fetchScheduledMessages:
|
|
5340
|
-
loadOlderMessages:
|
|
5341
|
-
loadOlderThreadMessages:
|
|
5342
|
-
ensureMessageLoaded:
|
|
5343
|
-
scheduleMessage:
|
|
5344
|
-
rescheduleMessage:
|
|
5345
|
-
removeScheduledMessage:
|
|
5346
|
-
editScheduledMessage:
|
|
5347
|
-
setReplyToMessage:
|
|
5348
|
-
setEditingMessage:
|
|
5349
|
-
openThread:
|
|
5350
|
-
closeThread:
|
|
5351
|
-
refreshVisibleMessages:
|
|
5352
|
-
fetchMessageReceipts:
|
|
5353
|
-
deleteMessage:
|
|
5354
|
-
votePoll:
|
|
5355
|
-
toggleReaction:
|
|
5356
|
-
translateMessage:
|
|
5338
|
+
fetchConversations: Ae,
|
|
5339
|
+
selectConversation: je,
|
|
5340
|
+
sendTextMessage: Ie,
|
|
5341
|
+
sendAttachmentMessage: Re,
|
|
5342
|
+
sendPollMessage: W,
|
|
5343
|
+
fetchScheduledMessages: Ge,
|
|
5344
|
+
loadOlderMessages: st,
|
|
5345
|
+
loadOlderThreadMessages: ct,
|
|
5346
|
+
ensureMessageLoaded: ut,
|
|
5347
|
+
scheduleMessage: Ke,
|
|
5348
|
+
rescheduleMessage: Ze,
|
|
5349
|
+
removeScheduledMessage: Ye,
|
|
5350
|
+
editScheduledMessage: Xe,
|
|
5351
|
+
setReplyToMessage: Me,
|
|
5352
|
+
setEditingMessage: Ne,
|
|
5353
|
+
openThread: Pe,
|
|
5354
|
+
closeThread: Fe,
|
|
5355
|
+
refreshVisibleMessages: wt,
|
|
5356
|
+
fetchMessageReceipts: St,
|
|
5357
|
+
deleteMessage: Ue,
|
|
5358
|
+
votePoll: ze,
|
|
5359
|
+
toggleReaction: Ve,
|
|
5360
|
+
translateMessage: We,
|
|
5357
5361
|
mentionDisplayNamesByUid: A,
|
|
5358
5362
|
rememberMentionDisplayNames: ee
|
|
5359
5363
|
};
|