@zean-chat/react-native 0.1.4 → 0.1.6
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/README.md +1 -1
- package/dist/components/AppMark.d.ts +1 -1
- package/dist/components/ChatHeader.d.ts +2 -2
- package/dist/components/ChatModal.d.ts +3 -2
- package/dist/components/ChatNotice.d.ts +1 -1
- package/dist/components/Composer.d.ts +3 -2
- package/dist/components/EmailForm.d.ts +1 -1
- package/dist/components/ImageViewer.d.ts +5 -2
- package/dist/components/MessageBubble.d.ts +5 -2
- package/dist/components/MessageFiles.d.ts +1 -1
- package/dist/components/MessageList.d.ts +2 -1
- package/dist/components/MessageMeta.d.ts +3 -0
- package/dist/components/PendingPhotos.d.ts +3 -0
- package/dist/components/PoweredBy.d.ts +1 -1
- package/dist/components/Skeleton.d.ts +3 -0
- package/dist/components/TypingBubble.d.ts +1 -1
- package/dist/components/ZeanChat.d.ts +1 -1
- package/dist/hooks/use-keyboard-overlap.d.ts +4 -3
- package/dist/hooks/use-pending-photos.d.ts +5 -4
- package/dist/hooks/use-rise-in.d.ts +8 -0
- package/dist/i18n/en.d.ts +5 -0
- package/dist/i18n/fr.d.ts +5 -0
- package/dist/index.js +1156 -543
- package/dist/interfaces.d.ts +6 -1
- package/dist/models/conversation.utils.d.ts +15 -0
- package/dist/models/sdk.constants.d.ts +20 -1
- package/dist/models/sdk.interface.d.ts +55 -13
- package/dist/models/sdk.utils.d.ts +2 -0
- package/package.json +10 -2
package/dist/index.js
CHANGED
|
@@ -26,10 +26,11 @@ __export(index_exports, {
|
|
|
26
26
|
module.exports = __toCommonJS(index_exports);
|
|
27
27
|
|
|
28
28
|
// src/components/ZeanChat.tsx
|
|
29
|
-
var
|
|
29
|
+
var import_react17 = require("react");
|
|
30
30
|
|
|
31
31
|
// ../shared/src/constants/app.ts
|
|
32
32
|
var APP_NAME = "Zean";
|
|
33
|
+
var APP_URL = "https://zean.chat";
|
|
33
34
|
var PRODUCTION_BACKEND_URL = "https://api.zean.chat";
|
|
34
35
|
var STAGING_APP_KEY_PREFIX = "app_stg_";
|
|
35
36
|
var STAGING_BACKEND_URL = "https://api-stg.zean.chat";
|
|
@@ -37,6 +38,8 @@ var SUPPORTED_LOCALES = ["fr", "en"];
|
|
|
37
38
|
var DEFAULT_LOCALE = "fr";
|
|
38
39
|
|
|
39
40
|
// ../shared/src/constants/conversations.ts
|
|
41
|
+
var INBOX_FILTERS = ["all", "mine", "unassigned"];
|
|
42
|
+
var INBOX_VIEWS = [...INBOX_FILTERS, "unread"];
|
|
40
43
|
var CONTACT_ID_MAX_LENGTH = 200;
|
|
41
44
|
var CONTACT_NAME_MAX_LENGTH = 120;
|
|
42
45
|
var CONTACT_PHONE_MAX_LENGTH = 32;
|
|
@@ -198,12 +201,19 @@ function minutesOf(clock) {
|
|
|
198
201
|
// ../sdk-core/src/chat.ts
|
|
199
202
|
var CLOCK_MS = 3e4;
|
|
200
203
|
var TYPING_SIGNAL_MS = 2e3;
|
|
204
|
+
var EMAIL_ASK_TYPING_MS = 1200;
|
|
201
205
|
var SECRET_BYTES = 32;
|
|
202
206
|
var SECRET_RETRY_MS = 2e3;
|
|
207
|
+
var KEPT_MESSAGES = 100;
|
|
208
|
+
var KEPT_VERSION = 1;
|
|
209
|
+
var LIVE_AFTER_CLOSE_MS = 2 * 6e4;
|
|
210
|
+
var ADVANCE_AFTER = WIDGET_PAGE_SIZE / 2;
|
|
203
211
|
function createChatStore(backend, options) {
|
|
204
212
|
const secretKey = `zean:${options.appKey}:device`;
|
|
205
213
|
const outboxKey = `zean:${options.appKey}:outbox`;
|
|
206
214
|
const attributesKey = `zean:${options.appKey}:attributes`;
|
|
215
|
+
const keptKey = `zean:${options.appKey}:conversation`;
|
|
216
|
+
const keep = options.keep === true;
|
|
207
217
|
const listeners2 = /* @__PURE__ */ new Set();
|
|
208
218
|
const stops = [];
|
|
209
219
|
let deviceSecret = null;
|
|
@@ -214,6 +224,14 @@ function createChatStore(backend, options) {
|
|
|
214
224
|
let limit = WIDGET_PAGE_SIZE;
|
|
215
225
|
let loadingOlder = false;
|
|
216
226
|
let stopMessages = null;
|
|
227
|
+
let stopTyping = null;
|
|
228
|
+
let kept = [];
|
|
229
|
+
let keptHasOlder = false;
|
|
230
|
+
let keptHistory = null;
|
|
231
|
+
let askedAfter;
|
|
232
|
+
let windowed = false;
|
|
233
|
+
let open2 = false;
|
|
234
|
+
let liveTimer = null;
|
|
217
235
|
let typing = null;
|
|
218
236
|
let typingTimer = null;
|
|
219
237
|
let lastTypingSignal = 0;
|
|
@@ -224,6 +242,10 @@ function createChatStore(backend, options) {
|
|
|
224
242
|
let reported = false;
|
|
225
243
|
let user = null;
|
|
226
244
|
let contactCode = null;
|
|
245
|
+
let emailGiven = false;
|
|
246
|
+
let wroteHere = false;
|
|
247
|
+
let emailAskWanted = false;
|
|
248
|
+
let emailAskTimer = null;
|
|
227
249
|
let generation = 0;
|
|
228
250
|
let identifying = null;
|
|
229
251
|
let identified = false;
|
|
@@ -232,6 +254,7 @@ function createChatStore(backend, options) {
|
|
|
232
254
|
let destroyed = false;
|
|
233
255
|
let state = derive();
|
|
234
256
|
const emit2 = () => {
|
|
257
|
+
holdEmailAsk();
|
|
235
258
|
state = derive();
|
|
236
259
|
for (const listener of listeners2) listener();
|
|
237
260
|
};
|
|
@@ -255,6 +278,7 @@ function createChatStore(backend, options) {
|
|
|
255
278
|
useSecret(secret);
|
|
256
279
|
outbox = await loadOutbox();
|
|
257
280
|
heldAttributes = { ...await loadAttributes(), ...heldAttributes };
|
|
281
|
+
if (keep) await loadKept();
|
|
258
282
|
if (destroyed) return;
|
|
259
283
|
emit2();
|
|
260
284
|
stops.push(
|
|
@@ -273,11 +297,50 @@ function createChatStore(backend, options) {
|
|
|
273
297
|
backend.watch("session", args(), handleSession, () => {
|
|
274
298
|
failedToLoad = true;
|
|
275
299
|
emit2();
|
|
276
|
-
}),
|
|
277
|
-
backend.watch("typing", args(), handleTyping, () => {
|
|
278
300
|
})
|
|
279
301
|
];
|
|
302
|
+
if (!keep || open2) watchLive();
|
|
303
|
+
}
|
|
304
|
+
function watchLive() {
|
|
280
305
|
watchMessages();
|
|
306
|
+
stopTyping?.();
|
|
307
|
+
stopTyping = backend.watch("typing", args(), handleTyping, () => {
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
function stopLive() {
|
|
311
|
+
if (keep && stopMessages) {
|
|
312
|
+
const hasOlder = serverHasOlder();
|
|
313
|
+
kept = serverMessages();
|
|
314
|
+
keptHasOlder = hasOlder;
|
|
315
|
+
page = { messages: [], hasOlder: false, seen: page.seen };
|
|
316
|
+
windowed = false;
|
|
317
|
+
}
|
|
318
|
+
stopMessages?.();
|
|
319
|
+
stopMessages = null;
|
|
320
|
+
stopTyping?.();
|
|
321
|
+
stopTyping = null;
|
|
322
|
+
typing = null;
|
|
323
|
+
}
|
|
324
|
+
function stopLiveLater() {
|
|
325
|
+
keepLive();
|
|
326
|
+
liveTimer = setTimeout(() => {
|
|
327
|
+
liveTimer = null;
|
|
328
|
+
stopLive();
|
|
329
|
+
emit2();
|
|
330
|
+
}, LIVE_AFTER_CLOSE_MS);
|
|
331
|
+
}
|
|
332
|
+
function keepLive() {
|
|
333
|
+
if (liveTimer) clearTimeout(liveTimer);
|
|
334
|
+
liveTimer = null;
|
|
335
|
+
}
|
|
336
|
+
function serverMessages() {
|
|
337
|
+
if (kept.length === 0) return page.messages;
|
|
338
|
+
if (page.messages.length === 0) return kept;
|
|
339
|
+
const keptIds = new Set(kept.map((message) => message.id));
|
|
340
|
+
return [...kept, ...page.messages.filter((message) => !keptIds.has(message.id))];
|
|
341
|
+
}
|
|
342
|
+
function serverHasOlder() {
|
|
343
|
+
return kept.length > 0 ? keptHasOlder : page.hasOlder;
|
|
281
344
|
}
|
|
282
345
|
function sendIdentity() {
|
|
283
346
|
const person = user;
|
|
@@ -312,6 +375,7 @@ function createChatStore(backend, options) {
|
|
|
312
375
|
);
|
|
313
376
|
session = result;
|
|
314
377
|
failedToLoad = false;
|
|
378
|
+
if (keep) checkKept(result);
|
|
315
379
|
emit2();
|
|
316
380
|
if ("report" in result && result.report && !reported) {
|
|
317
381
|
reported = true;
|
|
@@ -352,10 +416,17 @@ function createChatStore(backend, options) {
|
|
|
352
416
|
}
|
|
353
417
|
function watchMessages() {
|
|
354
418
|
stopMessages?.();
|
|
419
|
+
const after = !windowed && kept.length > 0 ? kept.at(-1).createdAt : void 0;
|
|
420
|
+
askedAfter = after;
|
|
355
421
|
stopMessages = backend.watch(
|
|
356
422
|
"messages",
|
|
357
|
-
{ ...args(), limit },
|
|
423
|
+
{ ...args(), limit: after === void 0 ? limit : WIDGET_PAGE_SIZE, ...after === void 0 ? {} : { after } },
|
|
358
424
|
(result) => {
|
|
425
|
+
if (after !== void 0 && result.hasOlder) windowed = true;
|
|
426
|
+
if (after === void 0 || windowed) {
|
|
427
|
+
kept = [];
|
|
428
|
+
keptHasOlder = false;
|
|
429
|
+
}
|
|
359
430
|
page = result;
|
|
360
431
|
pageLoaded = true;
|
|
361
432
|
loadingOlder = false;
|
|
@@ -364,6 +435,12 @@ function createChatStore(backend, options) {
|
|
|
364
435
|
outbox = outbox.filter((entry) => !stored.has(entry.clientId));
|
|
365
436
|
saveOutbox();
|
|
366
437
|
}
|
|
438
|
+
if (after !== void 0 && !windowed && result.messages.length >= ADVANCE_AFTER) {
|
|
439
|
+
kept = serverMessages();
|
|
440
|
+
page = { messages: [], hasOlder: false, seen: result.seen };
|
|
441
|
+
watchMessages();
|
|
442
|
+
}
|
|
443
|
+
saveKept();
|
|
367
444
|
emit2();
|
|
368
445
|
startOnce();
|
|
369
446
|
},
|
|
@@ -395,37 +472,124 @@ function createChatStore(backend, options) {
|
|
|
395
472
|
}
|
|
396
473
|
);
|
|
397
474
|
}
|
|
475
|
+
function statusOf() {
|
|
476
|
+
if (failedToLoad || session && hidesChat(session)) return "hidden";
|
|
477
|
+
const noConversation = keep && session !== null && "contact" in session && !session.contact?.historyKey;
|
|
478
|
+
return session && (pageLoaded || noConversation) ? session.state : "loading";
|
|
479
|
+
}
|
|
480
|
+
function wantsEmail() {
|
|
481
|
+
const app = session && "app" in session ? session.app : null;
|
|
482
|
+
const contact = session && "contact" in session ? session.contact : null;
|
|
483
|
+
return statusOf() === "ready" && !!contact && contact.email === null && !emailGiven && (app?.askEmail ?? false);
|
|
484
|
+
}
|
|
485
|
+
function holdEmailAsk() {
|
|
486
|
+
const wanted = wantsEmail();
|
|
487
|
+
if (wanted && !emailAskWanted && wroteHere) {
|
|
488
|
+
emailAskTimer = setTimeout(() => {
|
|
489
|
+
emailAskTimer = null;
|
|
490
|
+
emit2();
|
|
491
|
+
}, EMAIL_ASK_TYPING_MS);
|
|
492
|
+
} else if (!wanted && emailAskTimer) {
|
|
493
|
+
clearTimeout(emailAskTimer);
|
|
494
|
+
emailAskTimer = null;
|
|
495
|
+
}
|
|
496
|
+
emailAskWanted = wanted;
|
|
497
|
+
}
|
|
398
498
|
function derive() {
|
|
399
|
-
const status =
|
|
499
|
+
const status = statusOf();
|
|
400
500
|
const app = session && "app" in session ? session.app : null;
|
|
401
501
|
const contact = session && "contact" in session ? session.contact : null;
|
|
402
502
|
const locale = localeOf(options.languages, app?.defaultLocale ?? DEFAULT_LOCALE);
|
|
403
503
|
const fallback = DEFAULT_WIDGET_TEXTS;
|
|
404
504
|
const textOf = (key) => pickText(app?.texts[key], locale, app?.defaultLocale ?? DEFAULT_LOCALE, { fr: fallback.fr[key], en: fallback.en[key] });
|
|
405
505
|
const verified = session !== null && "identity" in session && session.identity === "verified";
|
|
406
|
-
const
|
|
506
|
+
const shown = serverMessages();
|
|
507
|
+
const hasOlder = serverHasOlder();
|
|
508
|
+
const stored = new Set(shown.map((message) => message.clientId));
|
|
407
509
|
const pending = outbox.filter((entry) => !stored.has(entry.clientId)).map(fromOutbox);
|
|
408
510
|
return {
|
|
409
511
|
status,
|
|
410
|
-
app: app ? {
|
|
512
|
+
app: app ? {
|
|
513
|
+
name: app.name,
|
|
514
|
+
color: app.color,
|
|
515
|
+
logoUrl: app.logoUrl,
|
|
516
|
+
launcher: app.launcher,
|
|
517
|
+
showBadge: app.showBadge,
|
|
518
|
+
hiddenPages: app.hiddenPages
|
|
519
|
+
} : null,
|
|
411
520
|
locale,
|
|
412
521
|
texts: { header: textOf("header"), welcome: textOf("welcome"), away: textOf("away") },
|
|
413
522
|
online: app ? app.teamOnline && isWithinBusinessHours(app.hours, /* @__PURE__ */ new Date()) : false,
|
|
414
|
-
messages: [...
|
|
523
|
+
messages: [...shown.map(fromServer), ...pending],
|
|
415
524
|
// Past the most the widget holds, older messages stay in the dashboard.
|
|
416
|
-
hasOlder:
|
|
417
|
-
atStart: !
|
|
525
|
+
hasOlder: hasOlder && Math.max(limit, shown.length) < WIDGET_MAX_MESSAGES,
|
|
526
|
+
atStart: !hasOlder,
|
|
418
527
|
loadingOlder,
|
|
419
528
|
seen: page.seen,
|
|
420
529
|
unread: contact?.unread ?? 0,
|
|
421
|
-
teamTyping: typing && typing.until > Date.now() ? { sender: typing.sender } : null,
|
|
530
|
+
teamTyping: typing && typing.until > Date.now() ? { sender: typing.sender } : emailAskTimer ? { sender: null } : null,
|
|
422
531
|
email: contact?.email ?? null,
|
|
423
532
|
known: contact !== null,
|
|
533
|
+
askEmail: emailAskWanted && !emailAskTimer,
|
|
534
|
+
emailGiven,
|
|
424
535
|
verified,
|
|
425
536
|
contactCode: verified ? null : contactCode,
|
|
426
537
|
connected
|
|
427
538
|
};
|
|
428
539
|
}
|
|
540
|
+
function checkKept(result) {
|
|
541
|
+
const history = "contact" in result ? result.contact?.historyKey ?? null : null;
|
|
542
|
+
if (history !== keptHistory) {
|
|
543
|
+
keptHistory = history;
|
|
544
|
+
dropKept();
|
|
545
|
+
}
|
|
546
|
+
if (hidesChat(result)) forgetKept();
|
|
547
|
+
else if (history !== null && !stopMessages && serverMessages().length === 0 && deviceSecret) {
|
|
548
|
+
watchLive();
|
|
549
|
+
if (!open2) stopLiveLater();
|
|
550
|
+
} else saveKept();
|
|
551
|
+
}
|
|
552
|
+
async function loadKept() {
|
|
553
|
+
try {
|
|
554
|
+
const saved = JSON.parse(await options.storage.getItem(keptKey) || "null");
|
|
555
|
+
if (saved?.version !== KEPT_VERSION || !Array.isArray(saved.messages) || !("app" in saved.session)) return;
|
|
556
|
+
session = saved.session;
|
|
557
|
+
kept = saved.messages;
|
|
558
|
+
keptHasOlder = saved.hasOlder;
|
|
559
|
+
keptHistory = saved.session.contact?.historyKey ?? null;
|
|
560
|
+
page = { messages: [], hasOlder: false, seen: saved.seen };
|
|
561
|
+
pageLoaded = kept.length > 0 || !saved.session.contact?.historyKey;
|
|
562
|
+
} catch {
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
function saveKept() {
|
|
566
|
+
if (!keep || !session || hidesChat(session)) return;
|
|
567
|
+
const current = session;
|
|
568
|
+
const shown = serverMessages();
|
|
569
|
+
const value = {
|
|
570
|
+
version: KEPT_VERSION,
|
|
571
|
+
// Told once per load, by the backend: never from what was kept.
|
|
572
|
+
session: { ...current, report: false },
|
|
573
|
+
messages: shown.slice(-KEPT_MESSAGES),
|
|
574
|
+
hasOlder: shown.length > KEPT_MESSAGES || serverHasOlder(),
|
|
575
|
+
seen: page.seen
|
|
576
|
+
};
|
|
577
|
+
quietly(() => options.storage.setItem(keptKey, JSON.stringify(value)));
|
|
578
|
+
}
|
|
579
|
+
function dropKept() {
|
|
580
|
+
kept = [];
|
|
581
|
+
keptHasOlder = false;
|
|
582
|
+
windowed = false;
|
|
583
|
+
if (stopMessages && askedAfter !== void 0) {
|
|
584
|
+
page = { messages: [], hasOlder: false, seen: false };
|
|
585
|
+
watchMessages();
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
function forgetKept() {
|
|
589
|
+
dropKept();
|
|
590
|
+
keptHistory = null;
|
|
591
|
+
if (keep) quietly(() => options.storage.setItem(keptKey, ""));
|
|
592
|
+
}
|
|
429
593
|
async function untilDone(task) {
|
|
430
594
|
for (; ; ) {
|
|
431
595
|
try {
|
|
@@ -489,6 +653,7 @@ function createChatStore(backend, options) {
|
|
|
489
653
|
};
|
|
490
654
|
outbox = [...outbox, entry];
|
|
491
655
|
saveOutbox();
|
|
656
|
+
wroteHere = true;
|
|
492
657
|
emit2();
|
|
493
658
|
if (started) deliver(entry);
|
|
494
659
|
},
|
|
@@ -511,11 +676,21 @@ function createChatStore(backend, options) {
|
|
|
511
676
|
},
|
|
512
677
|
loadOlder() {
|
|
513
678
|
if (!state.hasOlder || loadingOlder || !deviceSecret) return;
|
|
514
|
-
|
|
679
|
+
const shown = !windowed && kept.length > 0 ? serverMessages().length : limit;
|
|
680
|
+
limit = Math.min(shown + WIDGET_PAGE_SIZE, WIDGET_MAX_MESSAGES);
|
|
681
|
+
windowed = true;
|
|
515
682
|
loadingOlder = true;
|
|
516
683
|
emit2();
|
|
517
684
|
watchMessages();
|
|
518
685
|
},
|
|
686
|
+
setOpen(value) {
|
|
687
|
+
if (open2 === value) return;
|
|
688
|
+
open2 = value;
|
|
689
|
+
if (!keep) return;
|
|
690
|
+
keepLive();
|
|
691
|
+
if (!value) stopLiveLater();
|
|
692
|
+
else if (!stopMessages && deviceSecret) watchLive();
|
|
693
|
+
},
|
|
519
694
|
markRead() {
|
|
520
695
|
if (state.unread === 0 || !deviceSecret) return;
|
|
521
696
|
backend.call("markRead", args()).catch(() => {
|
|
@@ -532,6 +707,8 @@ function createChatStore(backend, options) {
|
|
|
532
707
|
if (!deviceSecret) return { ok: false, code: "not_found" };
|
|
533
708
|
try {
|
|
534
709
|
await backend.call("setEmail", { ...args(), email });
|
|
710
|
+
emailGiven = true;
|
|
711
|
+
emit2();
|
|
535
712
|
return { ok: true };
|
|
536
713
|
} catch (error) {
|
|
537
714
|
return { ok: false, code: codeOf(error) };
|
|
@@ -563,10 +740,13 @@ function createChatStore(backend, options) {
|
|
|
563
740
|
saveOutbox();
|
|
564
741
|
heldAttributes = {};
|
|
565
742
|
saveAttributes();
|
|
743
|
+
forgetKept();
|
|
744
|
+
emit2();
|
|
566
745
|
}
|
|
567
746
|
if (user?.id !== person.id) {
|
|
568
747
|
generation += 1;
|
|
569
748
|
contactCode = null;
|
|
749
|
+
emailGiven = false;
|
|
570
750
|
}
|
|
571
751
|
user = person;
|
|
572
752
|
identified = false;
|
|
@@ -607,14 +787,16 @@ function createChatStore(backend, options) {
|
|
|
607
787
|
user = null;
|
|
608
788
|
identified = false;
|
|
609
789
|
contactCode = null;
|
|
790
|
+
emailGiven = false;
|
|
610
791
|
identifying = null;
|
|
611
792
|
identifiedKnown = false;
|
|
612
793
|
if (deviceSecret) backend.call("signOut", args()).catch(() => {
|
|
613
794
|
});
|
|
614
795
|
for (const stop of watchers) stop();
|
|
615
796
|
watchers = [];
|
|
616
|
-
|
|
617
|
-
|
|
797
|
+
stopLive();
|
|
798
|
+
forgetKept();
|
|
799
|
+
keepLive();
|
|
618
800
|
deviceSecret = null;
|
|
619
801
|
outbox = [];
|
|
620
802
|
saveOutbox();
|
|
@@ -633,13 +815,23 @@ function createChatStore(backend, options) {
|
|
|
633
815
|
emit2();
|
|
634
816
|
watchAll();
|
|
635
817
|
},
|
|
818
|
+
async joinWithPass(pass) {
|
|
819
|
+
await starting;
|
|
820
|
+
await deviceKnown();
|
|
821
|
+
if (destroyed || !deviceSecret) return;
|
|
822
|
+
await backend.call("joinWithPass", { ...args(), pass }).catch(() => {
|
|
823
|
+
});
|
|
824
|
+
},
|
|
636
825
|
destroy() {
|
|
637
826
|
destroyed = true;
|
|
638
827
|
for (const resolve of deviceWaiters.splice(0)) resolve();
|
|
639
828
|
stopMessages?.();
|
|
829
|
+
stopTyping?.();
|
|
640
830
|
for (const stop of watchers) stop();
|
|
641
831
|
for (const stop of stops) stop();
|
|
642
832
|
if (typingTimer) clearTimeout(typingTimer);
|
|
833
|
+
keepLive();
|
|
834
|
+
if (emailAskTimer) clearTimeout(emailAskTimer);
|
|
643
835
|
listeners2.clear();
|
|
644
836
|
backend.close();
|
|
645
837
|
}
|
|
@@ -668,6 +860,16 @@ function fromOutbox(entry) {
|
|
|
668
860
|
error: entry.error
|
|
669
861
|
};
|
|
670
862
|
}
|
|
863
|
+
function hidesChat(result) {
|
|
864
|
+
return result.state === "not_found" || result.state === "domain_not_allowed";
|
|
865
|
+
}
|
|
866
|
+
function quietly(write) {
|
|
867
|
+
try {
|
|
868
|
+
void Promise.resolve(write()).catch(() => {
|
|
869
|
+
});
|
|
870
|
+
} catch {
|
|
871
|
+
}
|
|
872
|
+
}
|
|
671
873
|
function codeOf(error) {
|
|
672
874
|
const code2 = error?.code;
|
|
673
875
|
return typeof code2 === "string" ? code2 : "unknown";
|
|
@@ -6165,46 +6367,69 @@ function hexOf({ l, c, h }) {
|
|
|
6165
6367
|
}).join("")}`;
|
|
6166
6368
|
}
|
|
6167
6369
|
|
|
6370
|
+
// ../shared/src/constants/uploads.ts
|
|
6371
|
+
var MAX_IMAGE_BYTES = 2 * 1024 * 1024;
|
|
6372
|
+
var MAX_FILE_BYTES = 10 * 1024 * 1024;
|
|
6373
|
+
var MAX_ATTACHMENTS = 6;
|
|
6374
|
+
var MAX_IMAGE_SIDE = 1600;
|
|
6375
|
+
var IMAGE_TYPES = ["image/jpeg", "image/png", "image/webp"];
|
|
6376
|
+
|
|
6168
6377
|
// src/models/sdk.constants.ts
|
|
6169
6378
|
var OFFLINE_NOTICE_MS = 3e3;
|
|
6170
6379
|
var ANDROID_NAVIGATION_BAR = 48;
|
|
6380
|
+
var DEFAULT_MAX_PHOTOS = 4;
|
|
6171
6381
|
var LINK_RETRY_MS = 1500;
|
|
6172
6382
|
var LINK_RETRIES = 5;
|
|
6173
6383
|
var LINK_LIFETIME_MS = 50 * 60 * 1e3;
|
|
6174
6384
|
var NEUTRAL_COLORS = {
|
|
6175
6385
|
light: {
|
|
6176
|
-
background: "#
|
|
6177
|
-
surface: "#
|
|
6178
|
-
text: "#
|
|
6179
|
-
muted: "#
|
|
6180
|
-
border: "#
|
|
6181
|
-
danger: "#
|
|
6182
|
-
online: "#22c55e"
|
|
6386
|
+
background: "#f2f2f7",
|
|
6387
|
+
surface: "#ffffff",
|
|
6388
|
+
text: "#000000",
|
|
6389
|
+
muted: "#6c6c70",
|
|
6390
|
+
border: "#dee1e7",
|
|
6391
|
+
danger: "#ff3b30",
|
|
6392
|
+
online: "#22c55e",
|
|
6393
|
+
skeleton: "rgba(120,120,128,0.16)"
|
|
6183
6394
|
},
|
|
6184
6395
|
dark: {
|
|
6185
|
-
background: "#
|
|
6186
|
-
surface: "#
|
|
6187
|
-
text: "#
|
|
6188
|
-
muted: "#
|
|
6189
|
-
border: "#
|
|
6190
|
-
danger: "#
|
|
6191
|
-
online: "#22c55e"
|
|
6396
|
+
background: "#000000",
|
|
6397
|
+
surface: "#1c1c1e",
|
|
6398
|
+
text: "#ffffff",
|
|
6399
|
+
muted: "#98989f",
|
|
6400
|
+
border: "#38383a",
|
|
6401
|
+
danger: "#ff453a",
|
|
6402
|
+
online: "#22c55e",
|
|
6403
|
+
skeleton: "rgba(120,120,128,0.32)"
|
|
6192
6404
|
}
|
|
6193
6405
|
};
|
|
6406
|
+
var RADII = { inner: 4, pill: 14, group: 20, composer: 28 };
|
|
6407
|
+
var COMPOSER_BUTTON = 40;
|
|
6408
|
+
var RUN_GAP_MS = 5 * 60 * 1e3;
|
|
6409
|
+
var NEWEST_BUTTON_OFFSET = 120;
|
|
6410
|
+
var IMAGE_SIDE = 240;
|
|
6411
|
+
var ENTER_MS = 180;
|
|
6194
6412
|
var ICONS = {
|
|
6195
6413
|
close: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEgAAABICAYAAABV7bNHAAACH0lEQVR4nOzZPUoDURTF8esH1mKvNm5AwdK9qER7K8EFuIQ0iYI7ELV3IboCC0HBQlD0HpKBCJl34ryvKc4PLqIjMvmb94wvyyZByyZBCkQoEKFAhAIRCkQoEKFAhAIRCkQoEKFAhAIRCkQoEKFAhAIRCkQoEKFAhAIRCkSsWho704/P1g/J7if2GbTkM/R5ms5w+rVakt/PisW59Dmb+XzfZ9Pn3srDL3vsc2p/7weP8dE6iqm77vPa8jOufQY+P1YG4ox8judc+7LJvX5YBzF70Jq1B25utESkUBzAY+y8UmL2oBefm8B13PDI8htbexy48nm3jmL3oFufbZ/dlut7NtmT7iwPLOWjwHXEGViE2ECADRkRQpG2LO3G3WzIoWcO4p1YpBSBsMc8WDjSrqX768b2HEj2RyJFICgVqWgcSBUIckcqHgdSBoJckarEgdSBIHWkanEgRyBIFalqHMgVCGIjVY8DOQNB10i9iAO5A8F/I/UmDpQ+u2H/GuA6Ah0GvgevoKNfIS+qdKBFnh0hpY9RiiyxWYsstzbF40DpQNAlUpU4UCMQ4IHiCCR0VNLAnhN1ZBGjVqAGOypJcmQRo3ag0HKrtqxm1Q4EzXLDseiBz6fPuc+F9UDN97Dm2fD59nmznuhboN7Re/OEAhEKRCgQoUCEAhEKRCgQoUCEAhEKRCgQoUCEAhEKRCgQoUCEAhEKRCgQoUCEAhG/AAAA//+WQPYZAAAABklEQVQDAEAXdjf1x/3ZAAAAAElFTkSuQmCC",
|
|
6196
|
-
send: "data:image/png;base64,
|
|
6414
|
+
send: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEgAAABICAYAAABV7bNHAAAACXBIWXMAAAsTAAALEwEAmpwYAAABnklEQVR4nO3ZS2rDMBSF4bOCZAXdTaC9YOpBR515HZ11AR10oem0uIG0CFQIgehePRxb0vlBYOI8lC/yIDLAGGOMMcYYY033AODdD3fMLnoDcAbw68fZP8YAvFzhXI7X3oUEwHwDx40TgBEd43wHcP7H3COSGHG6RBqUyyqE5F7bdBK5crpaSUPiyuliJUnmyml6JUlhnKaQxIBzCpz7aRlJDDjuC34Gzn8Y32NsFecZwBR4jjv31BqSRODAAISWkCQSxwrUBJIk4MQAVY0kiTixQFUiSQZOClBVSJKJkwpUBZIUwMkB2jSSFMLJBdokkhj+lcf8484Fsu4UzH7ui7YDcCyIUwrIinT032GxxsI4JYGsSONaQHPiRlZJIAvSuMY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9eLyWH1jip8h4EKvtwx0s5D6Kf1rwTftwamWPU86jGAE8TdmPdvCF8jqE+5vFQb/Y9taQHb/VUHBBCi5IwQUpuCCFdQAAAP//SGoJjgAAAAZJREFUAwCco5s+yR6YMQAAAABJRU5ErkJggg==",
|
|
6200
6418
|
remove: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEgAAABICAYAAABV7bNHAAACi0lEQVR4nOybSUosQRCG4/keby3udeUFFFx6Gael4Epwr0dw44Q3cNp7BA+gJ3AhKLgQnOLHahzoyqiqjIxIIT74cSjozvo6MysrsnqCgiQTFCQJQQIhSCAECYQggRAkEIIEQpBACBIIQQIhSCAECYQggX+kw2zz84bqQK09uT3oD2eXc91kt/mfF+rt+Ut57HA2vvy9wJnmnJM9+LD3OWv0vT04x0saSI7dSc5dy2scclY4b2QD5OxxlsYce6aPtj7SAHLmoP/ULnjUUAtJKTkA5zh4pOTMQbec48RxNHiPyrNP7XLAAeeBBpI7B53Rx5wz13J8njNDZeak0ZyTkoOhvkoZ5ArC8LmgtKQ50p+4pWEFVObBXEFE9pLM5AANQcBKkqkcoCUIlJZkLgdoCgKlJLnIAdqCgLYkNzmghCCgJclVDiglCORKcpcDSgoCQyVVIQeUFgT6SqpGDtAqmEm80ueSv+3El1p+/4lppcC6uNWld6SwLqOYDLGvdBlubZjLAdaCwBBJLnKAhyDQR5KbHBDbPgJePajPZF2intQZD0FDrmRukqwF5VzmXSRZCuq6Qr4i2/JtEquVdJ/bh9HiVVpxm1zZLHpQ33srr42AsZQWNPTGsxpJJQXl3pVXIamUIK2ShbukEoK06zmukrQFlSp2uUnSFFS6EugiSUuQVZnUXJKGIOsasqmkXEFeBXYzSbmCtjnrieMli11dJVX5jCKwqgRKvbjKZxQty6TSllJ1zygecJbJtob82rznEY1vj9sziifNmy9ynjibnC3y41S7PVobh1OcF8491YFaezy/NvAriG0fgRAkEIIEQpBACBIIQQIhSCAECYQggRAkEIIEQpBACBJ4BwAA///VLeAmAAAABklEQVQ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1OWsKWVN8SD9Y+mwYjYssKLX4kH7QnJyJmFSkxt7XDz5blZNb0qM9wdfuXC3LQULEY4sP6QdNy1mbJN/ZZGhBTmqSQoqP6QdNy4lNUsx1SEo6Tf+LQzw/qPQNdpPJmeP0WiXn/eyQJJlOzhZPRJYkVSWnJEcAbwBuKuam7+/HyR9eALzqKyGEEEIIIYQQQghBEj+c/mnM4jHRJgAAAABJRU5ErkJggg==",
|
|
6422
|
+
down: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEgAAABICAYAAABV7bNHAAAACXBIWXMAAAsTAAALEwEAmpwYAAABCUlEQVR4nO3ZQQqDMBBG4f8EeqmCFqS9/yHstnRlSYlQimK0monJ+yDgzuE5LkQJAAAAAAAAAAAA+Kgldf64a2tJzXOR9JA0+OOuG8N5mol53IwmKkn91zDjefmnF1vn7/07T+9nje4+MYxVpLk443GzJhVoiBhpKY5ZoGrmFYsZKSSO2SvmXAMGPCpSSJyXn9FUK+kZMOiea34NvOdNiWgjRjpdnJiRThsnRqTTxzkyUjZxjoiUXZw9I2UbZ49I2cf5J1IxcbZEKi7O2k8Dq0+X02zSUNrmbNmk4jbn300qYnO2blJRm7N2k4rcnNBIxFn4XWP5+yhJdUo//AAAAAAAAAAAAKCcvAFtUXbojKVOAwAAAABJRU5ErkJggg=="
|
|
6202
6423
|
};
|
|
6203
6424
|
|
|
6204
6425
|
// src/models/sdk.utils.ts
|
|
6205
6426
|
function format(template, values) {
|
|
6206
6427
|
return template.replace(/\{(\w+)\}/g, (match, key) => key in values ? String(values[key]) : match);
|
|
6207
6428
|
}
|
|
6429
|
+
function photoLimit(chosen) {
|
|
6430
|
+
if (chosen === void 0 || !Number.isFinite(chosen)) return DEFAULT_MAX_PHOTOS;
|
|
6431
|
+
return Math.min(MAX_ATTACHMENTS, Math.max(1, Math.floor(chosen)));
|
|
6432
|
+
}
|
|
6208
6433
|
function chatColors(color, scheme) {
|
|
6209
6434
|
return { ...accentColors(color, scheme), ...NEUTRAL_COLORS[scheme] };
|
|
6210
6435
|
}
|
|
@@ -6255,8 +6480,8 @@ function hideKeyboard() {
|
|
|
6255
6480
|
}
|
|
6256
6481
|
|
|
6257
6482
|
// src/components/ChatModal.tsx
|
|
6258
|
-
var
|
|
6259
|
-
var
|
|
6483
|
+
var import_react16 = require("react");
|
|
6484
|
+
var import_react_native23 = require("react-native");
|
|
6260
6485
|
|
|
6261
6486
|
// src/hooks/use-app-active.ts
|
|
6262
6487
|
var import_react = require("react");
|
|
@@ -6321,9 +6546,14 @@ var en = {
|
|
|
6321
6546
|
photo_type: "This photo cannot be sent. Send a JPEG, PNG or WebP photo.",
|
|
6322
6547
|
photo_size: "{name} is too large. Send a smaller photo.",
|
|
6323
6548
|
too_many: "At most {count} photos per message.",
|
|
6549
|
+
too_many_one: "One photo per message.",
|
|
6324
6550
|
open_image: "Open the image",
|
|
6325
6551
|
close_image: "Close the image",
|
|
6326
|
-
open_file: "Open {name}"
|
|
6552
|
+
open_file: "Open {name}",
|
|
6553
|
+
today: "Today",
|
|
6554
|
+
yesterday: "Yesterday",
|
|
6555
|
+
newest: "Go to the latest messages",
|
|
6556
|
+
image_count: "{index} of {count}"
|
|
6327
6557
|
};
|
|
6328
6558
|
|
|
6329
6559
|
// src/i18n/fr.ts
|
|
@@ -6368,33 +6598,122 @@ var fr = {
|
|
|
6368
6598
|
photo_type: "Cette photo ne peut pas \xEAtre envoy\xE9e. Envoyez une photo JPEG, PNG ou WebP.",
|
|
6369
6599
|
photo_size: "{name} est trop volumineuse. Envoyez une photo plus l\xE9g\xE8re.",
|
|
6370
6600
|
too_many: "Au plus {count} photos par message.",
|
|
6601
|
+
too_many_one: "Une seule photo par message.",
|
|
6371
6602
|
open_image: "Ouvrir l'image",
|
|
6372
6603
|
close_image: "Fermer l'image",
|
|
6373
|
-
open_file: "Ouvrir {name}"
|
|
6604
|
+
open_file: "Ouvrir {name}",
|
|
6605
|
+
today: "Aujourd'hui",
|
|
6606
|
+
yesterday: "Hier",
|
|
6607
|
+
newest: "Aller aux derniers messages",
|
|
6608
|
+
image_count: "{index} sur {count}"
|
|
6374
6609
|
};
|
|
6375
6610
|
|
|
6376
6611
|
// src/components/ImageViewer.tsx
|
|
6612
|
+
var import_react3 = require("react");
|
|
6613
|
+
var import_react_native4 = require("react-native");
|
|
6614
|
+
|
|
6615
|
+
// src/components/Icon.tsx
|
|
6377
6616
|
var import_react_native3 = require("react-native");
|
|
6378
6617
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
6379
|
-
function
|
|
6618
|
+
function Icon({ name, color, size }) {
|
|
6619
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
6620
|
+
import_react_native3.Image,
|
|
6621
|
+
{
|
|
6622
|
+
source: { uri: ICONS[name] },
|
|
6623
|
+
style: { width: size, height: size, tintColor: color },
|
|
6624
|
+
accessibilityElementsHidden: true,
|
|
6625
|
+
importantForAccessibility: "no"
|
|
6626
|
+
}
|
|
6627
|
+
);
|
|
6628
|
+
}
|
|
6629
|
+
|
|
6630
|
+
// src/components/ImageViewer.tsx
|
|
6631
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
6632
|
+
function ImageViewer({ gallery, topInset, onClose }) {
|
|
6380
6633
|
const { t } = useChatContext();
|
|
6381
|
-
|
|
6634
|
+
const window2 = (0, import_react_native4.useWindowDimensions)();
|
|
6635
|
+
const [size, setSize] = (0, import_react3.useState)({ width: window2.width, height: window2.height });
|
|
6636
|
+
const [index, setIndex] = (0, import_react3.useState)(gallery.index);
|
|
6637
|
+
const count = gallery.images.length;
|
|
6638
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
6639
|
+
import_react_native4.View,
|
|
6640
|
+
{
|
|
6641
|
+
testID: "zean-viewer",
|
|
6642
|
+
style: styles.viewer,
|
|
6643
|
+
accessibilityViewIsModal: true,
|
|
6644
|
+
onLayout: (event) => setSize({ width: event.nativeEvent.layout.width, height: event.nativeEvent.layout.height }),
|
|
6645
|
+
children: [
|
|
6646
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
6647
|
+
import_react_native4.FlatList,
|
|
6648
|
+
{
|
|
6649
|
+
testID: "zean-images",
|
|
6650
|
+
horizontal: true,
|
|
6651
|
+
pagingEnabled: true,
|
|
6652
|
+
data: gallery.images,
|
|
6653
|
+
initialScrollIndex: gallery.index,
|
|
6654
|
+
getItemLayout: (_data, item) => ({ length: size.width, offset: size.width * item, index: item }),
|
|
6655
|
+
keyExtractor: (image, item) => `${item}:${image.url}`,
|
|
6656
|
+
showsHorizontalScrollIndicator: false,
|
|
6657
|
+
onMomentumScrollEnd: (event) => setIndex(Math.round(event.nativeEvent.contentOffset.x / size.width)),
|
|
6658
|
+
renderItem: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
6659
|
+
import_react_native4.ScrollView,
|
|
6660
|
+
{
|
|
6661
|
+
style: size,
|
|
6662
|
+
contentContainerStyle: styles.page,
|
|
6663
|
+
maximumZoomScale: 4,
|
|
6664
|
+
minimumZoomScale: 1,
|
|
6665
|
+
centerContent: true,
|
|
6666
|
+
showsHorizontalScrollIndicator: false,
|
|
6667
|
+
showsVerticalScrollIndicator: false,
|
|
6668
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native4.Image, { source: { uri: item.url }, style: size, resizeMode: "contain", accessibilityLabel: item.name })
|
|
6669
|
+
}
|
|
6670
|
+
)
|
|
6671
|
+
}
|
|
6672
|
+
),
|
|
6673
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_native4.View, { style: [styles.bar, { top: topInset + 12 }], children: [
|
|
6674
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
6675
|
+
import_react_native4.Pressable,
|
|
6676
|
+
{
|
|
6677
|
+
onPress: onClose,
|
|
6678
|
+
accessibilityRole: "button",
|
|
6679
|
+
accessibilityLabel: t.close_image,
|
|
6680
|
+
hitSlop: 8,
|
|
6681
|
+
style: ({ pressed }) => [styles.close, pressed && styles.pressed],
|
|
6682
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "close", color: "#ffffff", size: 18 })
|
|
6683
|
+
}
|
|
6684
|
+
),
|
|
6685
|
+
count > 1 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native4.Text, { style: styles.count, children: format(t.image_count, { index: index + 1, count }) })
|
|
6686
|
+
] })
|
|
6687
|
+
]
|
|
6688
|
+
}
|
|
6689
|
+
);
|
|
6382
6690
|
}
|
|
6383
|
-
var styles =
|
|
6384
|
-
viewer: { ...
|
|
6385
|
-
|
|
6691
|
+
var styles = import_react_native4.StyleSheet.create({
|
|
6692
|
+
viewer: { ...import_react_native4.StyleSheet.absoluteFill, backgroundColor: "#000000" },
|
|
6693
|
+
page: { flexGrow: 1, alignItems: "center", justifyContent: "center" },
|
|
6694
|
+
bar: { position: "absolute", left: 16, right: 16, flexDirection: "row", alignItems: "center", gap: 12 },
|
|
6695
|
+
close: {
|
|
6696
|
+
width: 36,
|
|
6697
|
+
height: 36,
|
|
6698
|
+
borderRadius: 18,
|
|
6699
|
+
alignItems: "center",
|
|
6700
|
+
justifyContent: "center",
|
|
6701
|
+
backgroundColor: "rgba(255,255,255,0.18)"
|
|
6702
|
+
},
|
|
6703
|
+
pressed: { opacity: 0.6 },
|
|
6704
|
+
count: { color: "#ffffff", fontSize: 15, fontWeight: "600" }
|
|
6386
6705
|
});
|
|
6387
6706
|
|
|
6388
6707
|
// src/components/ChatScreen.tsx
|
|
6389
|
-
var
|
|
6390
|
-
var
|
|
6708
|
+
var import_react15 = require("react");
|
|
6709
|
+
var import_react_native22 = require("react-native");
|
|
6391
6710
|
|
|
6392
6711
|
// src/hooks/use-connection-lost.ts
|
|
6393
|
-
var
|
|
6712
|
+
var import_react4 = require("react");
|
|
6394
6713
|
function useConnectionLost(connected) {
|
|
6395
|
-
const [wasConnected, setWasConnected] = (0,
|
|
6396
|
-
const [lost, setLost] = (0,
|
|
6397
|
-
(0,
|
|
6714
|
+
const [wasConnected, setWasConnected] = (0, import_react4.useState)(connected);
|
|
6715
|
+
const [lost, setLost] = (0, import_react4.useState)(false);
|
|
6716
|
+
(0, import_react4.useEffect)(() => {
|
|
6398
6717
|
if (connected) {
|
|
6399
6718
|
setWasConnected(true);
|
|
6400
6719
|
setLost(false);
|
|
@@ -6408,31 +6727,24 @@ function useConnectionLost(connected) {
|
|
|
6408
6727
|
}
|
|
6409
6728
|
|
|
6410
6729
|
// src/hooks/use-keyboard-overlap.ts
|
|
6411
|
-
var
|
|
6412
|
-
var
|
|
6730
|
+
var import_react5 = require("react");
|
|
6731
|
+
var import_react_native5 = require("react-native");
|
|
6413
6732
|
function useKeyboardOverlap(ref) {
|
|
6414
|
-
const [overlap, setOverlap] = (0,
|
|
6415
|
-
(0,
|
|
6416
|
-
if (
|
|
6417
|
-
const
|
|
6418
|
-
|
|
6419
|
-
|
|
6420
|
-
setOverlap(
|
|
6733
|
+
const [overlap, setOverlap] = (0, import_react5.useState)(0);
|
|
6734
|
+
(0, import_react5.useEffect)(() => {
|
|
6735
|
+
if (import_react_native5.Platform.OS === "ios") {
|
|
6736
|
+
const frame = import_react_native5.Keyboard.addListener("keyboardWillChangeFrame", (event) => {
|
|
6737
|
+
const next = Math.max(0, Math.round(import_react_native5.Dimensions.get("screen").height - event.endCoordinates.screenY));
|
|
6738
|
+
if (event.duration > 0) import_react_native5.LayoutAnimation.configureNext(import_react_native5.LayoutAnimation.create(event.duration, "keyboard"));
|
|
6739
|
+
setOverlap(next);
|
|
6421
6740
|
});
|
|
6422
|
-
|
|
6423
|
-
animate(event.duration);
|
|
6424
|
-
setOverlap(0);
|
|
6425
|
-
});
|
|
6426
|
-
return () => {
|
|
6427
|
-
show2.remove();
|
|
6428
|
-
hide2.remove();
|
|
6429
|
-
};
|
|
6741
|
+
return () => frame.remove();
|
|
6430
6742
|
}
|
|
6431
|
-
const show =
|
|
6743
|
+
const show = import_react_native5.Keyboard.addListener("keyboardDidShow", (event) => {
|
|
6432
6744
|
const keyboardTop = event.endCoordinates.screenY;
|
|
6433
6745
|
ref.current?.measureInWindow((_x, y, _width, height) => setOverlap(Math.max(0, Math.round(y + height - keyboardTop))));
|
|
6434
6746
|
});
|
|
6435
|
-
const hide =
|
|
6747
|
+
const hide = import_react_native5.Keyboard.addListener("keyboardDidHide", () => setOverlap(0));
|
|
6436
6748
|
return () => {
|
|
6437
6749
|
show.remove();
|
|
6438
6750
|
hide.remove();
|
|
@@ -6445,74 +6757,72 @@ function useKeyboardOverlap(ref) {
|
|
|
6445
6757
|
var import_react_native7 = require("react-native");
|
|
6446
6758
|
|
|
6447
6759
|
// src/components/AppMark.tsx
|
|
6448
|
-
var
|
|
6449
|
-
var
|
|
6760
|
+
var import_react_native6 = require("react-native");
|
|
6761
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
6450
6762
|
function AppMark({ app }) {
|
|
6451
6763
|
const { colors } = useChatContext();
|
|
6452
|
-
if (app.logoUrl)
|
|
6453
|
-
|
|
6764
|
+
if (app.logoUrl) {
|
|
6765
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
6766
|
+
import_react_native6.Image,
|
|
6767
|
+
{
|
|
6768
|
+
source: { uri: app.logoUrl },
|
|
6769
|
+
style: [styles2.mark, styles2.logo, { borderColor: colors.border }],
|
|
6770
|
+
accessibilityIgnoresInvertColors: true
|
|
6771
|
+
}
|
|
6772
|
+
);
|
|
6773
|
+
}
|
|
6774
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native6.View, { style: [styles2.mark, styles2.bubble], children: [0, 1, 2].map((dot) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native6.View, { style: [styles2.dot, { backgroundColor: colors.primary }] }, dot)) });
|
|
6454
6775
|
}
|
|
6455
|
-
var styles2 =
|
|
6456
|
-
mark: { width:
|
|
6457
|
-
|
|
6458
|
-
|
|
6776
|
+
var styles2 = import_react_native6.StyleSheet.create({
|
|
6777
|
+
mark: { width: 40, height: 40, borderRadius: 12, borderWidth: 1, borderColor: "transparent", backgroundColor: "#ffffff" },
|
|
6778
|
+
logo: { borderRadius: 20 },
|
|
6779
|
+
bubble: { flexDirection: "row", alignItems: "center", justifyContent: "center", gap: 4, borderBottomLeftRadius: 4 },
|
|
6780
|
+
dot: { width: 5, height: 5, borderRadius: 2.5 }
|
|
6459
6781
|
});
|
|
6460
6782
|
|
|
6461
|
-
// src/components/Icon.tsx
|
|
6462
|
-
var import_react_native6 = require("react-native");
|
|
6463
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
6464
|
-
function Icon({ name, color, size = 20 }) {
|
|
6465
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
6466
|
-
import_react_native6.Image,
|
|
6467
|
-
{
|
|
6468
|
-
source: { uri: ICONS[name] },
|
|
6469
|
-
style: { width: size, height: size, tintColor: color },
|
|
6470
|
-
accessibilityElementsHidden: true,
|
|
6471
|
-
importantForAccessibility: "no"
|
|
6472
|
-
}
|
|
6473
|
-
);
|
|
6474
|
-
}
|
|
6475
|
-
|
|
6476
6783
|
// src/components/ChatHeader.tsx
|
|
6477
6784
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
6478
|
-
function ChatHeader({ app, online,
|
|
6785
|
+
function ChatHeader({ app, online, topInset, onClose }) {
|
|
6479
6786
|
const { t, colors } = useChatContext();
|
|
6480
6787
|
const onPrimary = { color: colors.primaryForeground };
|
|
6481
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.
|
|
6482
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react_native7.View, {
|
|
6483
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.
|
|
6484
|
-
|
|
6485
|
-
online && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native7.View, { style: [styles3.online, { backgroundColor: colors.online, borderColor: colors.primary }] })
|
|
6486
|
-
] }),
|
|
6487
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react_native7.View, { style: styles3.titles, children: [
|
|
6488
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native7.Text, { style: [styles3.name, onPrimary], numberOfLines: 1, accessibilityRole: "header", children: app.name }),
|
|
6489
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native7.Text, { style: [styles3.status, onPrimary], children: online ? t.online : t.away })
|
|
6490
|
-
] }),
|
|
6491
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
6492
|
-
import_react_native7.Pressable,
|
|
6493
|
-
{
|
|
6494
|
-
onPress: onClose,
|
|
6495
|
-
accessibilityRole: "button",
|
|
6496
|
-
accessibilityLabel: t.close_chat,
|
|
6497
|
-
hitSlop: 8,
|
|
6498
|
-
style: ({ pressed }) => [styles3.close, pressed && styles3.pressed],
|
|
6499
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: "close", color: colors.primaryForeground })
|
|
6500
|
-
}
|
|
6501
|
-
)
|
|
6788
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native7.View, { style: [styles3.header, { backgroundColor: colors.primary, paddingTop: topInset + 16 }], children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react_native7.View, { style: styles3.row, children: [
|
|
6789
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react_native7.View, { children: [
|
|
6790
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AppMark, { app }),
|
|
6791
|
+
online && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native7.View, { style: [styles3.online, { backgroundColor: colors.online, borderColor: colors.primary }] })
|
|
6502
6792
|
] }),
|
|
6503
|
-
|
|
6504
|
-
|
|
6793
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react_native7.View, { style: styles3.titles, children: [
|
|
6794
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native7.Text, { style: [styles3.name, onPrimary], numberOfLines: 1, accessibilityRole: "header", children: app.name }),
|
|
6795
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native7.Text, { style: [styles3.status, onPrimary], numberOfLines: 1, children: online ? t.online : t.away })
|
|
6796
|
+
] }),
|
|
6797
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
6798
|
+
import_react_native7.Pressable,
|
|
6799
|
+
{
|
|
6800
|
+
onPress: onClose,
|
|
6801
|
+
accessibilityRole: "button",
|
|
6802
|
+
accessibilityLabel: t.close_chat,
|
|
6803
|
+
hitSlop: 8,
|
|
6804
|
+
style: ({ pressed }) => [styles3.close, pressed && styles3.pressed],
|
|
6805
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: "close", color: colors.primaryForeground, size: 18 })
|
|
6806
|
+
}
|
|
6807
|
+
)
|
|
6808
|
+
] }) });
|
|
6505
6809
|
}
|
|
6506
6810
|
var styles3 = import_react_native7.StyleSheet.create({
|
|
6507
|
-
header: {
|
|
6508
|
-
row: { flexDirection: "row", alignItems: "center", gap:
|
|
6509
|
-
online: { position: "absolute", right: -
|
|
6510
|
-
titles: { flex: 1, minWidth: 0 },
|
|
6511
|
-
name: { fontSize:
|
|
6512
|
-
status: { fontSize:
|
|
6513
|
-
close: {
|
|
6514
|
-
|
|
6515
|
-
|
|
6811
|
+
header: { paddingHorizontal: 16, paddingBottom: 20 },
|
|
6812
|
+
row: { flexDirection: "row", alignItems: "center", gap: 12 },
|
|
6813
|
+
online: { position: "absolute", right: -3, bottom: -3, width: 14, height: 14, borderRadius: 7, borderWidth: 2 },
|
|
6814
|
+
titles: { flex: 1, minWidth: 0, gap: 1 },
|
|
6815
|
+
name: { fontSize: 18, fontWeight: "700", letterSpacing: -0.3 },
|
|
6816
|
+
status: { fontSize: 14, fontWeight: "500", opacity: 0.85 },
|
|
6817
|
+
close: {
|
|
6818
|
+
width: 34,
|
|
6819
|
+
height: 34,
|
|
6820
|
+
alignItems: "center",
|
|
6821
|
+
justifyContent: "center",
|
|
6822
|
+
borderRadius: 17,
|
|
6823
|
+
backgroundColor: "rgba(255,255,255,0.18)"
|
|
6824
|
+
},
|
|
6825
|
+
pressed: { opacity: 0.6 }
|
|
6516
6826
|
});
|
|
6517
6827
|
|
|
6518
6828
|
// src/components/ChatNotice.tsx
|
|
@@ -6523,11 +6833,21 @@ function ChatNotice({ children }) {
|
|
|
6523
6833
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_native8.Text, { accessibilityLiveRegion: "polite", style: [styles4.notice, { backgroundColor: colors.surface, color: colors.muted }], children });
|
|
6524
6834
|
}
|
|
6525
6835
|
var styles4 = import_react_native8.StyleSheet.create({
|
|
6526
|
-
notice: {
|
|
6836
|
+
notice: {
|
|
6837
|
+
alignSelf: "center",
|
|
6838
|
+
maxWidth: 640,
|
|
6839
|
+
borderRadius: 20,
|
|
6840
|
+
paddingHorizontal: 16,
|
|
6841
|
+
paddingVertical: 12,
|
|
6842
|
+
textAlign: "center",
|
|
6843
|
+
fontSize: 14,
|
|
6844
|
+
lineHeight: 20,
|
|
6845
|
+
overflow: "hidden"
|
|
6846
|
+
}
|
|
6527
6847
|
});
|
|
6528
6848
|
|
|
6529
6849
|
// src/components/ContactCodeCard.tsx
|
|
6530
|
-
var
|
|
6850
|
+
var import_react6 = require("react");
|
|
6531
6851
|
var import_react_native9 = require("react-native");
|
|
6532
6852
|
|
|
6533
6853
|
// ../shared/src/constants/auth.ts
|
|
@@ -6538,9 +6858,9 @@ var CODE_MAX_AGE_SECONDS = 15 * 60;
|
|
|
6538
6858
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
6539
6859
|
function ContactCodeCard({ code: code2, onDismiss }) {
|
|
6540
6860
|
const { chat: chat2, t, colors } = useChatContext();
|
|
6541
|
-
const [value, setValue] = (0,
|
|
6542
|
-
const [error, setError] = (0,
|
|
6543
|
-
const [busy, setBusy] = (0,
|
|
6861
|
+
const [value, setValue] = (0, import_react6.useState)("");
|
|
6862
|
+
const [error, setError] = (0, import_react6.useState)(null);
|
|
6863
|
+
const [busy, setBusy] = (0, import_react6.useState)(false);
|
|
6544
6864
|
const errorOf = (reason) => reason === "contact_code_invalid" ? t.code_invalid : reason === "contact_code_expired" ? t.code_expired : reason === "rate_limited" ? t.code_rate_limited : t.error;
|
|
6545
6865
|
const handleSend = async () => {
|
|
6546
6866
|
setBusy(true);
|
|
@@ -6563,7 +6883,7 @@ function ContactCodeCard({ code: code2, onDismiss }) {
|
|
|
6563
6883
|
if (!result.ok) setError(errorOf(result.code));
|
|
6564
6884
|
};
|
|
6565
6885
|
const label = format(code2.sent ? t.code_label : t.code_prompt, { email: code2.email });
|
|
6566
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_react_native9.View, { style: [styles5.card, {
|
|
6886
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_react_native9.View, { style: [styles5.card, { backgroundColor: colors.surface }], children: [
|
|
6567
6887
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native9.Text, { style: [styles5.prompt, { color: colors.text }], children: label }),
|
|
6568
6888
|
code2.sent ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_react_native9.View, { style: styles5.row, children: [
|
|
6569
6889
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
@@ -6580,7 +6900,10 @@ function ContactCodeCard({ code: code2, onDismiss }) {
|
|
|
6580
6900
|
autoComplete: "one-time-code",
|
|
6581
6901
|
textContentType: "oneTimeCode",
|
|
6582
6902
|
returnKeyType: "done",
|
|
6583
|
-
style: [
|
|
6903
|
+
style: [
|
|
6904
|
+
styles5.input,
|
|
6905
|
+
{ backgroundColor: colors.background, borderColor: error ? colors.danger : colors.background, color: colors.text }
|
|
6906
|
+
]
|
|
6584
6907
|
}
|
|
6585
6908
|
),
|
|
6586
6909
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
@@ -6589,8 +6912,8 @@ function ContactCodeCard({ code: code2, onDismiss }) {
|
|
|
6589
6912
|
onPress: () => void handleSubmit(),
|
|
6590
6913
|
disabled: busy,
|
|
6591
6914
|
accessibilityRole: "button",
|
|
6592
|
-
style: [styles5.
|
|
6593
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native9.Text, { style: [styles5.
|
|
6915
|
+
style: ({ pressed }) => [styles5.button, { backgroundColor: colors.primary }, (busy || pressed) && styles5.dim],
|
|
6916
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native9.Text, { style: [styles5.buttonText, { color: colors.primaryForeground }], children: t.code_submit })
|
|
6594
6917
|
}
|
|
6595
6918
|
)
|
|
6596
6919
|
] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_react_native9.View, { style: styles5.actions, children: [
|
|
@@ -6600,52 +6923,44 @@ function ContactCodeCard({ code: code2, onDismiss }) {
|
|
|
6600
6923
|
onPress: () => void handleSend(),
|
|
6601
6924
|
disabled: busy,
|
|
6602
6925
|
accessibilityRole: "button",
|
|
6603
|
-
style: [styles5.
|
|
6604
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native9.Text, { style: [styles5.
|
|
6926
|
+
style: ({ pressed }) => [styles5.button, { backgroundColor: colors.primary }, (busy || pressed) && styles5.dim],
|
|
6927
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native9.Text, { style: [styles5.buttonText, { color: colors.primaryForeground }], children: t.code_send })
|
|
6605
6928
|
}
|
|
6606
6929
|
),
|
|
6607
6930
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native9.Pressable, { onPress: onDismiss, accessibilityRole: "button", hitSlop: 8, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native9.Text, { style: [styles5.link, { color: colors.muted }], children: t.code_dismiss }) })
|
|
6608
6931
|
] }),
|
|
6609
6932
|
error && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native9.Text, { accessibilityLiveRegion: "polite", style: [styles5.error, { color: colors.danger }], children: error }),
|
|
6610
|
-
code2.sent && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native9.Pressable, { onPress: () => void handleSend(), disabled: busy, accessibilityRole: "button", hitSlop: 8, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native9.Text, { style: [styles5.link, { color: colors.
|
|
6933
|
+
code2.sent && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native9.Pressable, { onPress: () => void handleSend(), disabled: busy, accessibilityRole: "button", hitSlop: 8, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native9.Text, { style: [styles5.link, { color: colors.primaryText }, busy && styles5.dim], children: t.code_resend }) })
|
|
6611
6934
|
] });
|
|
6612
6935
|
}
|
|
6613
6936
|
var styles5 = import_react_native9.StyleSheet.create({
|
|
6614
|
-
card: { gap:
|
|
6615
|
-
prompt: { fontSize:
|
|
6937
|
+
card: { gap: 10, padding: 16, borderRadius: RADII.group },
|
|
6938
|
+
prompt: { fontSize: 15, lineHeight: 21, fontWeight: "500" },
|
|
6616
6939
|
row: { flexDirection: "row", gap: 8 },
|
|
6617
|
-
actions: { flexDirection: "row", alignItems: "center", gap:
|
|
6940
|
+
actions: { flexDirection: "row", alignItems: "center", gap: 16 },
|
|
6618
6941
|
input: {
|
|
6619
6942
|
flex: 1,
|
|
6620
6943
|
minWidth: 0,
|
|
6944
|
+
height: 44,
|
|
6621
6945
|
borderWidth: 1,
|
|
6622
|
-
borderRadius:
|
|
6623
|
-
paddingHorizontal:
|
|
6624
|
-
|
|
6625
|
-
|
|
6626
|
-
letterSpacing: 4
|
|
6946
|
+
borderRadius: RADII.pill,
|
|
6947
|
+
paddingHorizontal: 14,
|
|
6948
|
+
fontSize: 18,
|
|
6949
|
+
letterSpacing: 6
|
|
6627
6950
|
},
|
|
6628
|
-
|
|
6629
|
-
|
|
6630
|
-
|
|
6631
|
-
|
|
6632
|
-
|
|
6633
|
-
error: { fontSize: 12 }
|
|
6951
|
+
button: { height: 44, justifyContent: "center", paddingHorizontal: 16, borderRadius: RADII.pill },
|
|
6952
|
+
buttonText: { fontSize: 15, fontWeight: "600" },
|
|
6953
|
+
dim: { opacity: 0.6 },
|
|
6954
|
+
link: { fontSize: 13, fontWeight: "600" },
|
|
6955
|
+
error: { fontSize: 13 }
|
|
6634
6956
|
});
|
|
6635
6957
|
|
|
6636
6958
|
// src/components/Composer.tsx
|
|
6637
|
-
var
|
|
6638
|
-
var
|
|
6639
|
-
|
|
6640
|
-
// ../shared/src/constants/uploads.ts
|
|
6641
|
-
var MAX_IMAGE_BYTES = 2 * 1024 * 1024;
|
|
6642
|
-
var MAX_FILE_BYTES = 10 * 1024 * 1024;
|
|
6643
|
-
var MAX_ATTACHMENTS = 6;
|
|
6644
|
-
var MAX_IMAGE_SIDE = 1600;
|
|
6645
|
-
var IMAGE_TYPES = ["image/jpeg", "image/png", "image/webp"];
|
|
6959
|
+
var import_react8 = require("react");
|
|
6960
|
+
var import_react_native11 = require("react-native");
|
|
6646
6961
|
|
|
6647
6962
|
// src/hooks/use-pending-photos.ts
|
|
6648
|
-
var
|
|
6963
|
+
var import_react7 = require("react");
|
|
6649
6964
|
|
|
6650
6965
|
// ../shared/src/utils/files.ts
|
|
6651
6966
|
function isImage(type) {
|
|
@@ -6655,37 +6970,43 @@ function isImage(type) {
|
|
|
6655
6970
|
// src/hooks/use-pending-photos.ts
|
|
6656
6971
|
var lastId = 0;
|
|
6657
6972
|
function usePendingPhotos() {
|
|
6658
|
-
const { chat: chat2, t } = useChatContext();
|
|
6659
|
-
const [photos, setPhotos] = (0,
|
|
6660
|
-
const [problem, setProblem] = (0,
|
|
6973
|
+
const { chat: chat2, t, maxPhotos } = useChatContext();
|
|
6974
|
+
const [photos, setPhotos] = (0, import_react7.useState)([]);
|
|
6975
|
+
const [problem, setProblem] = (0, import_react7.useState)(null);
|
|
6976
|
+
const [sending, setSending] = (0, import_react7.useState)(false);
|
|
6977
|
+
const tooMany = maxPhotos === 1 ? t.too_many_one : format(t.too_many, { count: maxPhotos });
|
|
6661
6978
|
const update = (id, patch) => setPhotos((current) => current.map((photo) => photo.id === id ? { ...photo, ...patch } : photo));
|
|
6662
|
-
const upload = async (
|
|
6979
|
+
const upload = async (photo) => {
|
|
6980
|
+
update(photo.id, { status: "uploading" });
|
|
6663
6981
|
try {
|
|
6664
6982
|
const file = await (await fetch(photo.uri)).blob();
|
|
6665
6983
|
if (file.size > MAX_FILE_BYTES) {
|
|
6666
6984
|
setProblem(format(t.photo_size, { name: photo.name }));
|
|
6667
|
-
update(id, { status: "failed" });
|
|
6668
|
-
return;
|
|
6985
|
+
update(photo.id, { status: "failed" });
|
|
6986
|
+
return null;
|
|
6669
6987
|
}
|
|
6670
|
-
const { key, url } = await chat2.uploadLink(type, file.size);
|
|
6671
|
-
const response = await fetch(url, { method: "PUT", headers: { "Content-Type": type }, body: file });
|
|
6988
|
+
const { key, url } = await chat2.uploadLink(photo.type, file.size);
|
|
6989
|
+
const response = await fetch(url, { method: "PUT", headers: { "Content-Type": photo.type }, body: file });
|
|
6672
6990
|
if (!response.ok) throw new Error(`Upload failed: ${response.status}`);
|
|
6673
6991
|
const attachment = {
|
|
6674
6992
|
key,
|
|
6675
6993
|
name: photo.name,
|
|
6676
|
-
type,
|
|
6994
|
+
type: photo.type,
|
|
6677
6995
|
size: file.size,
|
|
6678
6996
|
...photo.width && photo.height ? { width: photo.width, height: photo.height } : {}
|
|
6679
6997
|
};
|
|
6680
|
-
update(id, { status: "ready", attachment });
|
|
6998
|
+
update(photo.id, { status: "ready", attachment });
|
|
6999
|
+
return attachment;
|
|
6681
7000
|
} catch {
|
|
6682
|
-
update(id, { status: "failed" });
|
|
7001
|
+
update(photo.id, { status: "failed" });
|
|
7002
|
+
return null;
|
|
6683
7003
|
}
|
|
6684
7004
|
};
|
|
6685
7005
|
const add = (picked) => {
|
|
6686
7006
|
setProblem(null);
|
|
6687
|
-
const room =
|
|
6688
|
-
if (picked.length > room) setProblem(
|
|
7007
|
+
const room = maxPhotos - photos.length;
|
|
7008
|
+
if (picked.length > room) setProblem(tooMany);
|
|
7009
|
+
const added = [];
|
|
6689
7010
|
for (const photo of picked.slice(0, Math.max(0, room))) {
|
|
6690
7011
|
if (!photo.type || !isImage(photo.type)) {
|
|
6691
7012
|
setProblem(t.photo_type);
|
|
@@ -6696,29 +7017,33 @@ function usePendingPhotos() {
|
|
|
6696
7017
|
continue;
|
|
6697
7018
|
}
|
|
6698
7019
|
lastId += 1;
|
|
6699
|
-
const
|
|
6700
|
-
|
|
6701
|
-
void upload(id, photo, photo.type);
|
|
7020
|
+
const { uri, name, type, width, height } = photo;
|
|
7021
|
+
added.push({ id: `photo_${lastId}`, uri, name, type, width, height, status: "picked", attachment: null });
|
|
6702
7022
|
}
|
|
7023
|
+
setPhotos((current) => [...current, ...added]);
|
|
6703
7024
|
};
|
|
6704
7025
|
const remove = (id) => setPhotos((current) => current.filter((photo) => photo.id !== id));
|
|
6705
|
-
const
|
|
6706
|
-
const ready = photos.flatMap((photo) => photo.status === "ready" && photo.attachment ? [photo.attachment] : []);
|
|
6707
|
-
setPhotos([]);
|
|
7026
|
+
const send = async () => {
|
|
6708
7027
|
setProblem(null);
|
|
6709
|
-
|
|
7028
|
+
setSending(true);
|
|
7029
|
+
const attachments = await Promise.all(photos.map((photo) => photo.attachment ?? upload(photo)));
|
|
7030
|
+
setSending(false);
|
|
7031
|
+
if (attachments.includes(null)) return null;
|
|
7032
|
+
setPhotos([]);
|
|
7033
|
+
return attachments;
|
|
6710
7034
|
};
|
|
6711
7035
|
return {
|
|
6712
7036
|
photos,
|
|
6713
7037
|
problem,
|
|
6714
7038
|
/** Photos that still fit in the message. */
|
|
6715
|
-
room:
|
|
7039
|
+
room: maxPhotos - photos.length,
|
|
7040
|
+
/** Why no more photos fit. */
|
|
7041
|
+
tooMany,
|
|
6716
7042
|
add,
|
|
6717
7043
|
remove,
|
|
6718
|
-
|
|
6719
|
-
|
|
6720
|
-
|
|
6721
|
-
ready: photos.some((photo) => photo.status === "ready")
|
|
7044
|
+
send,
|
|
7045
|
+
sending,
|
|
7046
|
+
showProblem: setProblem
|
|
6722
7047
|
};
|
|
6723
7048
|
}
|
|
6724
7049
|
|
|
@@ -6783,7 +7108,7 @@ function imagePicker(module2) {
|
|
|
6783
7108
|
}
|
|
6784
7109
|
function photoOf({ uri, fileName, type, width, height, fileSize }) {
|
|
6785
7110
|
const name = fileName || uri.split("/").pop() || "photo.jpg";
|
|
6786
|
-
const extension = name.split(".").pop()
|
|
7111
|
+
const extension = name.split(".").pop().toLowerCase();
|
|
6787
7112
|
return {
|
|
6788
7113
|
uri,
|
|
6789
7114
|
name,
|
|
@@ -6793,24 +7118,81 @@ function photoOf({ uri, fileName, type, width, height, fileSize }) {
|
|
|
6793
7118
|
};
|
|
6794
7119
|
}
|
|
6795
7120
|
|
|
6796
|
-
// src/components/
|
|
7121
|
+
// src/components/PendingPhotos.tsx
|
|
7122
|
+
var import_react_native10 = require("react-native");
|
|
6797
7123
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
7124
|
+
function PendingPhotos({ photos, locked, onRemove }) {
|
|
7125
|
+
const { t, colors } = useChatContext();
|
|
7126
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native10.ScrollView, { horizontal: true, showsHorizontalScrollIndicator: false, contentContainerStyle: styles6.photos, children: photos.map((photo) => {
|
|
7127
|
+
const failed = photo.status === "failed";
|
|
7128
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
7129
|
+
import_react_native10.View,
|
|
7130
|
+
{
|
|
7131
|
+
accessible: true,
|
|
7132
|
+
accessibilityLabel: `${photo.name}, ${photo.status === "uploading" ? t.uploading : failed ? t.not_sent : t.ready}`,
|
|
7133
|
+
style: [styles6.photo, { borderColor: failed ? colors.danger : colors.border }],
|
|
7134
|
+
children: [
|
|
7135
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native10.Image, { source: { uri: photo.uri }, style: styles6.preview }),
|
|
7136
|
+
photo.status === "uploading" && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native10.View, { style: styles6.cover, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native10.ActivityIndicator, { color: "#ffffff" }) }),
|
|
7137
|
+
failed && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native10.View, { style: styles6.cover, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native10.Text, { style: styles6.failed, children: "!" }) }),
|
|
7138
|
+
!locked && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
7139
|
+
import_react_native10.Pressable,
|
|
7140
|
+
{
|
|
7141
|
+
onPress: () => onRemove(photo.id),
|
|
7142
|
+
accessibilityRole: "button",
|
|
7143
|
+
accessibilityLabel: format(t.remove_photo, { name: photo.name }),
|
|
7144
|
+
hitSlop: 8,
|
|
7145
|
+
style: styles6.remove,
|
|
7146
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { name: "remove", color: "#ffffff", size: 12 })
|
|
7147
|
+
}
|
|
7148
|
+
)
|
|
7149
|
+
]
|
|
7150
|
+
},
|
|
7151
|
+
photo.id
|
|
7152
|
+
);
|
|
7153
|
+
}) });
|
|
7154
|
+
}
|
|
7155
|
+
var styles6 = import_react_native10.StyleSheet.create({
|
|
7156
|
+
photos: { gap: 8, paddingTop: 6, paddingRight: 6 },
|
|
7157
|
+
photo: { width: 64, height: 64, borderRadius: 14, borderWidth: 1, overflow: "hidden" },
|
|
7158
|
+
preview: { width: "100%", height: "100%" },
|
|
7159
|
+
cover: { ...import_react_native10.StyleSheet.absoluteFill, alignItems: "center", justifyContent: "center", backgroundColor: "rgba(0,0,0,0.35)" },
|
|
7160
|
+
failed: { color: "#ffffff", fontSize: 20, fontWeight: "700" },
|
|
7161
|
+
remove: {
|
|
7162
|
+
position: "absolute",
|
|
7163
|
+
top: 4,
|
|
7164
|
+
right: 4,
|
|
7165
|
+
width: 20,
|
|
7166
|
+
height: 20,
|
|
7167
|
+
borderRadius: 10,
|
|
7168
|
+
alignItems: "center",
|
|
7169
|
+
justifyContent: "center",
|
|
7170
|
+
backgroundColor: "rgba(0,0,0,0.6)"
|
|
7171
|
+
}
|
|
7172
|
+
});
|
|
7173
|
+
|
|
7174
|
+
// src/components/Composer.tsx
|
|
7175
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
6798
7176
|
function Composer() {
|
|
6799
7177
|
const { chat: chat2, t, colors } = useChatContext();
|
|
6800
|
-
const [text, setText] = (0,
|
|
6801
|
-
const
|
|
7178
|
+
const [text, setText] = (0, import_react8.useState)("");
|
|
7179
|
+
const typed = (0, import_react8.useRef)("");
|
|
6802
7180
|
const pending = usePendingPhotos();
|
|
6803
7181
|
const picker = photoPicker();
|
|
6804
|
-
const canSend = !pending.
|
|
6805
|
-
const
|
|
6806
|
-
|
|
6807
|
-
|
|
6808
|
-
|
|
7182
|
+
const canSend = !pending.sending && (text.trim().length > 0 || pending.photos.length > 0);
|
|
7183
|
+
const changeText = (value) => {
|
|
7184
|
+
typed.current = value;
|
|
7185
|
+
setText(value);
|
|
7186
|
+
};
|
|
7187
|
+
const handleSend = async () => {
|
|
7188
|
+
const attachments = pending.photos.length > 0 ? await pending.send() : [];
|
|
7189
|
+
if (!attachments) return;
|
|
7190
|
+
chat2.send(typed.current.trim(), attachments);
|
|
7191
|
+
changeText("");
|
|
6809
7192
|
};
|
|
6810
7193
|
const handlePick = async () => {
|
|
6811
|
-
if (!picker) return;
|
|
6812
7194
|
if (pending.room <= 0) {
|
|
6813
|
-
pending.showProblem(
|
|
7195
|
+
pending.showProblem(pending.tooMany);
|
|
6814
7196
|
return;
|
|
6815
7197
|
}
|
|
6816
7198
|
try {
|
|
@@ -6820,119 +7202,166 @@ function Composer() {
|
|
|
6820
7202
|
pending.showProblem(t.error);
|
|
6821
7203
|
}
|
|
6822
7204
|
};
|
|
6823
|
-
return /* @__PURE__ */ (0,
|
|
6824
|
-
pending.photos.length > 0 && /* @__PURE__ */ (0,
|
|
6825
|
-
|
|
6826
|
-
|
|
6827
|
-
|
|
6828
|
-
|
|
6829
|
-
|
|
6830
|
-
|
|
6831
|
-
|
|
6832
|
-
|
|
6833
|
-
|
|
6834
|
-
|
|
6835
|
-
|
|
6836
|
-
|
|
6837
|
-
|
|
6838
|
-
|
|
6839
|
-
|
|
6840
|
-
|
|
6841
|
-
style: styles6.remove,
|
|
6842
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { name: "remove", color: colors.muted, size: 14 })
|
|
6843
|
-
}
|
|
6844
|
-
)
|
|
6845
|
-
]
|
|
6846
|
-
},
|
|
6847
|
-
photo.id
|
|
6848
|
-
)) }),
|
|
6849
|
-
pending.problem && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native10.Text, { accessibilityLiveRegion: "polite", style: [styles6.problem, { color: colors.danger }], children: pending.problem }),
|
|
6850
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_react_native10.View, { style: [styles6.field, { backgroundColor: colors.background, borderColor: focused ? colors.primary : colors.border }], children: [
|
|
6851
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
6852
|
-
import_react_native10.TextInput,
|
|
7205
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_react_native11.View, { style: styles7.composer, children: [
|
|
7206
|
+
pending.photos.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(PendingPhotos, { photos: pending.photos, locked: pending.sending, onRemove: pending.remove }),
|
|
7207
|
+
pending.problem && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_native11.Text, { accessibilityLiveRegion: "polite", style: [styles7.problem, { color: colors.danger }], children: pending.problem }),
|
|
7208
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_react_native11.View, { style: [styles7.pill, { backgroundColor: colors.surface }], children: [
|
|
7209
|
+
picker && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
7210
|
+
import_react_native11.Pressable,
|
|
7211
|
+
{
|
|
7212
|
+
onPress: () => void handlePick(),
|
|
7213
|
+
disabled: pending.sending,
|
|
7214
|
+
accessibilityRole: "button",
|
|
7215
|
+
accessibilityLabel: t.attach,
|
|
7216
|
+
accessibilityState: { disabled: pending.sending },
|
|
7217
|
+
style: ({ pressed }) => [styles7.button, pressed && { backgroundColor: colors.background }],
|
|
7218
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "photo", color: colors.muted, size: 22 })
|
|
7219
|
+
}
|
|
7220
|
+
),
|
|
7221
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
7222
|
+
import_react_native11.TextInput,
|
|
6853
7223
|
{
|
|
6854
7224
|
value: text,
|
|
6855
7225
|
onChangeText: (value) => {
|
|
6856
|
-
|
|
7226
|
+
changeText(value);
|
|
6857
7227
|
chat2.typing();
|
|
6858
7228
|
},
|
|
6859
|
-
onFocus: () => setFocused(true),
|
|
6860
|
-
onBlur: () => setFocused(false),
|
|
6861
7229
|
multiline: true,
|
|
6862
7230
|
maxLength: MAX_MESSAGE_LENGTH,
|
|
6863
7231
|
placeholder: t.placeholder,
|
|
6864
7232
|
placeholderTextColor: colors.muted,
|
|
6865
7233
|
accessibilityLabel: t.placeholder,
|
|
6866
|
-
style: [
|
|
7234
|
+
style: [styles7.input, { color: colors.text }, !picker && styles7.inputAlone]
|
|
6867
7235
|
}
|
|
6868
7236
|
),
|
|
6869
|
-
/* @__PURE__ */ (0,
|
|
6870
|
-
|
|
6871
|
-
|
|
6872
|
-
|
|
6873
|
-
|
|
6874
|
-
|
|
6875
|
-
|
|
6876
|
-
|
|
6877
|
-
|
|
6878
|
-
|
|
6879
|
-
|
|
6880
|
-
|
|
6881
|
-
|
|
6882
|
-
|
|
6883
|
-
|
|
6884
|
-
|
|
6885
|
-
disabled: !canSend,
|
|
6886
|
-
accessibilityRole: "button",
|
|
6887
|
-
accessibilityLabel: t.send,
|
|
6888
|
-
accessibilityState: { disabled: !canSend },
|
|
6889
|
-
hitSlop: 6,
|
|
6890
|
-
style: ({ pressed }) => [styles6.send, pressed && styles6.pressed],
|
|
6891
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { name: "send", color: canSend ? colors.primary : colors.border, size: 22 })
|
|
6892
|
-
}
|
|
6893
|
-
)
|
|
6894
|
-
] })
|
|
7237
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
7238
|
+
import_react_native11.Pressable,
|
|
7239
|
+
{
|
|
7240
|
+
onPress: () => void handleSend(),
|
|
7241
|
+
disabled: !canSend,
|
|
7242
|
+
accessibilityRole: "button",
|
|
7243
|
+
accessibilityLabel: t.send,
|
|
7244
|
+
accessibilityState: { disabled: !canSend },
|
|
7245
|
+
style: ({ pressed }) => [
|
|
7246
|
+
styles7.button,
|
|
7247
|
+
{ backgroundColor: canSend ? colors.primary : colors.skeleton },
|
|
7248
|
+
pressed && styles7.pressed
|
|
7249
|
+
],
|
|
7250
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "send", color: canSend ? colors.primaryForeground : colors.muted, size: 20 })
|
|
7251
|
+
}
|
|
7252
|
+
)
|
|
6895
7253
|
] })
|
|
6896
7254
|
] });
|
|
6897
7255
|
}
|
|
6898
|
-
var
|
|
7256
|
+
var styles7 = import_react_native11.StyleSheet.create({
|
|
6899
7257
|
composer: { gap: 8 },
|
|
6900
|
-
|
|
6901
|
-
|
|
6902
|
-
|
|
7258
|
+
problem: { fontSize: 12, paddingHorizontal: 8 },
|
|
7259
|
+
pill: { flexDirection: "row", alignItems: "flex-end", gap: 4, padding: 4, borderRadius: RADII.composer },
|
|
7260
|
+
button: {
|
|
7261
|
+
width: COMPOSER_BUTTON,
|
|
7262
|
+
height: COMPOSER_BUTTON,
|
|
7263
|
+
borderRadius: COMPOSER_BUTTON / 2,
|
|
6903
7264
|
alignItems: "center",
|
|
6904
|
-
|
|
6905
|
-
height: 44,
|
|
6906
|
-
paddingLeft: 4,
|
|
6907
|
-
paddingRight: 28,
|
|
6908
|
-
borderRadius: 8,
|
|
6909
|
-
borderWidth: 1
|
|
7265
|
+
justifyContent: "center"
|
|
6910
7266
|
},
|
|
6911
|
-
|
|
6912
|
-
|
|
6913
|
-
|
|
6914
|
-
|
|
6915
|
-
|
|
6916
|
-
|
|
6917
|
-
|
|
6918
|
-
|
|
6919
|
-
|
|
6920
|
-
|
|
7267
|
+
// Five lines of 22 points, and the room around them.
|
|
7268
|
+
input: {
|
|
7269
|
+
flex: 1,
|
|
7270
|
+
minHeight: COMPOSER_BUTTON,
|
|
7271
|
+
maxHeight: 5 * 22 + 18,
|
|
7272
|
+
paddingHorizontal: 4,
|
|
7273
|
+
paddingTop: 9,
|
|
7274
|
+
paddingBottom: 9,
|
|
7275
|
+
fontSize: 16,
|
|
7276
|
+
lineHeight: 22
|
|
7277
|
+
},
|
|
7278
|
+
inputAlone: { paddingLeft: 12 },
|
|
7279
|
+
pressed: { transform: [{ scale: 0.92 }] }
|
|
6921
7280
|
});
|
|
6922
7281
|
|
|
6923
7282
|
// src/components/MessageList.tsx
|
|
6924
|
-
var
|
|
6925
|
-
var
|
|
7283
|
+
var import_react14 = require("react");
|
|
7284
|
+
var import_react_native20 = require("react-native");
|
|
7285
|
+
|
|
7286
|
+
// src/models/conversation.utils.ts
|
|
7287
|
+
function authorOf(message) {
|
|
7288
|
+
if (message.from === "contact") return "contact";
|
|
7289
|
+
return `team:${message.sender?.name ?? ""}:${message.sender?.image ?? ""}`;
|
|
7290
|
+
}
|
|
7291
|
+
function startOfDay(timestamp) {
|
|
7292
|
+
const day = new Date(timestamp);
|
|
7293
|
+
day.setHours(0, 0, 0, 0);
|
|
7294
|
+
return day.getTime();
|
|
7295
|
+
}
|
|
7296
|
+
function sameDay(left, right) {
|
|
7297
|
+
return startOfDay(left) === startOfDay(right);
|
|
7298
|
+
}
|
|
7299
|
+
function joins(older, newer) {
|
|
7300
|
+
return older.status !== "failed" && authorOf(older) === authorOf(newer) && newer.createdAt - older.createdAt < RUN_GAP_MS && sameDay(older.createdAt, newer.createdAt);
|
|
7301
|
+
}
|
|
7302
|
+
function conversationRows(messages, seen, welcome) {
|
|
7303
|
+
const all = welcome ? [welcome, ...messages] : [...messages];
|
|
7304
|
+
const lastReply = all.findLastIndex((message) => message.from === "team" && message.sender !== null);
|
|
7305
|
+
return all.map((message, index) => {
|
|
7306
|
+
const older = all[index - 1];
|
|
7307
|
+
const newer = all[index + 1];
|
|
7308
|
+
const isWelcome = message === welcome;
|
|
7309
|
+
return {
|
|
7310
|
+
message,
|
|
7311
|
+
startsRun: !older || !joins(older, message),
|
|
7312
|
+
endsRun: !newer || !joins(message, newer),
|
|
7313
|
+
// Alone, the welcome has no day: there is nothing to date.
|
|
7314
|
+
startsDay: isWelcome ? messages.length > 0 : !older || !sameDay(older.createdAt, message.createdAt),
|
|
7315
|
+
receipt: receiptOf(message, seen || index < lastReply),
|
|
7316
|
+
welcome: isWelcome
|
|
7317
|
+
};
|
|
7318
|
+
});
|
|
7319
|
+
}
|
|
7320
|
+
function receiptOf(message, seen) {
|
|
7321
|
+
if (message.from === "team" || message.status === "failed") return null;
|
|
7322
|
+
if (message.status === "sending") return "sending";
|
|
7323
|
+
return seen ? "seen" : "sent";
|
|
7324
|
+
}
|
|
7325
|
+
var DATE_STYLES = {
|
|
7326
|
+
time: { hour: "2-digit", minute: "2-digit" },
|
|
7327
|
+
weekday: { weekday: "long" },
|
|
7328
|
+
day: { day: "numeric", month: "short" },
|
|
7329
|
+
dayYear: { day: "numeric", month: "short", year: "numeric" }
|
|
7330
|
+
};
|
|
7331
|
+
var formats = /* @__PURE__ */ new Map();
|
|
7332
|
+
function formatDate(timestamp, locale, style) {
|
|
7333
|
+
const key = `${locale}:${style}`;
|
|
7334
|
+
let format2 = formats.get(key);
|
|
7335
|
+
if (!format2) {
|
|
7336
|
+
format2 = new Intl.DateTimeFormat(locale, DATE_STYLES[style]);
|
|
7337
|
+
formats.set(key, format2);
|
|
7338
|
+
}
|
|
7339
|
+
return format2.format(timestamp);
|
|
7340
|
+
}
|
|
7341
|
+
function messageTime(timestamp, locale) {
|
|
7342
|
+
return formatDate(timestamp, locale, "time");
|
|
7343
|
+
}
|
|
7344
|
+
function dayLabel(timestamp, now, locale, t) {
|
|
7345
|
+
const today = startOfDay(now);
|
|
7346
|
+
const day = startOfDay(timestamp);
|
|
7347
|
+
if (day === today) return t.today;
|
|
7348
|
+
if (day === startOfDay(today - 1)) return t.yesterday;
|
|
7349
|
+
const weekAgo = new Date(today);
|
|
7350
|
+
weekAgo.setDate(weekAgo.getDate() - 6);
|
|
7351
|
+
if (day >= weekAgo.getTime()) return formatDate(timestamp, locale, "weekday");
|
|
7352
|
+
const sameYear = new Date(timestamp).getFullYear() === new Date(now).getFullYear();
|
|
7353
|
+
return formatDate(timestamp, locale, sameYear ? "day" : "dayYear");
|
|
7354
|
+
}
|
|
6926
7355
|
|
|
6927
7356
|
// src/components/EmailForm.tsx
|
|
6928
|
-
var
|
|
6929
|
-
var
|
|
6930
|
-
var
|
|
7357
|
+
var import_react9 = require("react");
|
|
7358
|
+
var import_react_native12 = require("react-native");
|
|
7359
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
6931
7360
|
function EmailForm({ onSubmit }) {
|
|
6932
7361
|
const { t, colors } = useChatContext();
|
|
6933
|
-
const [email, setEmail] = (0,
|
|
6934
|
-
const [error, setError] = (0,
|
|
6935
|
-
const [busy, setBusy] = (0,
|
|
7362
|
+
const [email, setEmail] = (0, import_react9.useState)("");
|
|
7363
|
+
const [error, setError] = (0, import_react9.useState)(null);
|
|
7364
|
+
const [busy, setBusy] = (0, import_react9.useState)(false);
|
|
6936
7365
|
const handleSubmit = async () => {
|
|
6937
7366
|
const address = normaliseEmail(email);
|
|
6938
7367
|
if (!isEmail(address)) {
|
|
@@ -6945,11 +7374,11 @@ function EmailForm({ onSubmit }) {
|
|
|
6945
7374
|
setBusy(false);
|
|
6946
7375
|
if (!result.ok) setError(result.code === "invalid_email" ? t.email_invalid : t.error);
|
|
6947
7376
|
};
|
|
6948
|
-
return /* @__PURE__ */ (0,
|
|
6949
|
-
/* @__PURE__ */ (0,
|
|
6950
|
-
/* @__PURE__ */ (0,
|
|
6951
|
-
/* @__PURE__ */ (0,
|
|
6952
|
-
|
|
7377
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_react_native12.View, { style: [styles8.card, { backgroundColor: colors.surface }], children: [
|
|
7378
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native12.Text, { style: [styles8.prompt, { color: colors.text }], children: t.email_prompt }),
|
|
7379
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_react_native12.View, { style: styles8.row, children: [
|
|
7380
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
7381
|
+
import_react_native12.TextInput,
|
|
6953
7382
|
{
|
|
6954
7383
|
value: email,
|
|
6955
7384
|
onChangeText: setEmail,
|
|
@@ -6963,39 +7392,54 @@ function EmailForm({ onSubmit }) {
|
|
|
6963
7392
|
autoComplete: "email",
|
|
6964
7393
|
textContentType: "emailAddress",
|
|
6965
7394
|
returnKeyType: "send",
|
|
6966
|
-
style: [
|
|
7395
|
+
style: [
|
|
7396
|
+
styles8.input,
|
|
7397
|
+
{ backgroundColor: colors.background, borderColor: error ? colors.danger : colors.background, color: colors.text }
|
|
7398
|
+
]
|
|
6967
7399
|
}
|
|
6968
7400
|
),
|
|
6969
|
-
/* @__PURE__ */ (0,
|
|
6970
|
-
|
|
7401
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
7402
|
+
import_react_native12.Pressable,
|
|
6971
7403
|
{
|
|
6972
7404
|
onPress: () => void handleSubmit(),
|
|
6973
7405
|
disabled: busy,
|
|
6974
7406
|
accessibilityRole: "button",
|
|
6975
|
-
style: [
|
|
6976
|
-
children: /* @__PURE__ */ (0,
|
|
7407
|
+
style: ({ pressed }) => [styles8.button, { backgroundColor: colors.primary }, (busy || pressed) && styles8.dim],
|
|
7408
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native12.Text, { style: [styles8.buttonText, { color: colors.primaryForeground }], children: t.email_submit })
|
|
6977
7409
|
}
|
|
6978
7410
|
)
|
|
6979
7411
|
] }),
|
|
6980
|
-
error && /* @__PURE__ */ (0,
|
|
7412
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native12.Text, { accessibilityLiveRegion: "polite", style: [styles8.error, { color: colors.danger }], children: error })
|
|
6981
7413
|
] });
|
|
6982
7414
|
}
|
|
6983
|
-
var
|
|
6984
|
-
|
|
6985
|
-
prompt: { fontSize:
|
|
7415
|
+
var styles8 = import_react_native12.StyleSheet.create({
|
|
7416
|
+
card: { gap: 10, marginHorizontal: 12, marginTop: 14, padding: 16, borderRadius: RADII.group },
|
|
7417
|
+
prompt: { fontSize: 15, lineHeight: 21, fontWeight: "500" },
|
|
6986
7418
|
row: { flexDirection: "row", gap: 8 },
|
|
6987
|
-
input: { flex: 1, minWidth: 0, borderWidth: 1, borderRadius:
|
|
6988
|
-
|
|
6989
|
-
|
|
6990
|
-
|
|
6991
|
-
error: { fontSize:
|
|
7419
|
+
input: { flex: 1, minWidth: 0, height: 44, borderWidth: 1, borderRadius: RADII.pill, paddingHorizontal: 14, fontSize: 16 },
|
|
7420
|
+
button: { height: 44, justifyContent: "center", paddingHorizontal: 16, borderRadius: RADII.pill },
|
|
7421
|
+
buttonText: { fontSize: 15, fontWeight: "600" },
|
|
7422
|
+
dim: { opacity: 0.6 },
|
|
7423
|
+
error: { fontSize: 13 }
|
|
6992
7424
|
});
|
|
6993
7425
|
|
|
6994
7426
|
// src/components/MessageBubble.tsx
|
|
6995
|
-
var
|
|
7427
|
+
var import_react_native18 = require("react-native");
|
|
7428
|
+
|
|
7429
|
+
// src/hooks/use-rise-in.ts
|
|
7430
|
+
var import_react10 = require("react");
|
|
7431
|
+
var import_react_native13 = require("react-native");
|
|
7432
|
+
function useRiseIn(fresh) {
|
|
7433
|
+
const progress = (0, import_react10.useRef)(new import_react_native13.Animated.Value(fresh ? 0 : 1)).current;
|
|
7434
|
+
(0, import_react10.useEffect)(() => {
|
|
7435
|
+
if (!fresh) return;
|
|
7436
|
+
import_react_native13.Animated.timing(progress, { toValue: 1, duration: ENTER_MS, useNativeDriver: true }).start();
|
|
7437
|
+
}, [fresh, progress]);
|
|
7438
|
+
return { opacity: progress, transform: [{ translateY: progress.interpolate({ inputRange: [0, 1], outputRange: [8, 0] }) }] };
|
|
7439
|
+
}
|
|
6996
7440
|
|
|
6997
7441
|
// src/components/MessageFiles.tsx
|
|
6998
|
-
var
|
|
7442
|
+
var import_react_native15 = require("react-native");
|
|
6999
7443
|
|
|
7000
7444
|
// ../shared/src/utils/file-links.ts
|
|
7001
7445
|
var encoder = new TextEncoder();
|
|
@@ -7008,13 +7452,13 @@ function withFileName(url, name) {
|
|
|
7008
7452
|
}
|
|
7009
7453
|
|
|
7010
7454
|
// src/hooks/use-attachment-links.ts
|
|
7011
|
-
var
|
|
7455
|
+
var import_react11 = require("react");
|
|
7012
7456
|
var signed = /* @__PURE__ */ new Map();
|
|
7013
7457
|
function useAttachmentLinks(chat2, keys, stored) {
|
|
7014
|
-
const [links, setLinks] = (0,
|
|
7015
|
-
const [attempt, setAttempt] = (0,
|
|
7458
|
+
const [links, setLinks] = (0, import_react11.useState)(() => cachedLinks(keys));
|
|
7459
|
+
const [attempt, setAttempt] = (0, import_react11.useState)(0);
|
|
7016
7460
|
const wanted = keys.join("|");
|
|
7017
|
-
(0,
|
|
7461
|
+
(0, import_react11.useEffect)(() => {
|
|
7018
7462
|
if (!stored) return;
|
|
7019
7463
|
const list = wanted ? wanted.split("|") : [];
|
|
7020
7464
|
const missing = list.filter((key) => (signed.get(key)?.until ?? 0) < Date.now());
|
|
@@ -7043,51 +7487,79 @@ function cachedLinks(keys) {
|
|
|
7043
7487
|
return new Map(keys.flatMap((key) => signed.has(key) ? [[key, signed.get(key).url]] : []));
|
|
7044
7488
|
}
|
|
7045
7489
|
|
|
7490
|
+
// src/components/Skeleton.tsx
|
|
7491
|
+
var import_react12 = require("react");
|
|
7492
|
+
var import_react_native14 = require("react-native");
|
|
7493
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
7494
|
+
function Skeleton({ style }) {
|
|
7495
|
+
const { colors } = useChatContext();
|
|
7496
|
+
const opacity = (0, import_react12.useRef)(new import_react_native14.Animated.Value(1)).current;
|
|
7497
|
+
(0, import_react12.useEffect)(() => {
|
|
7498
|
+
const breathe = import_react_native14.Animated.loop(
|
|
7499
|
+
import_react_native14.Animated.sequence([
|
|
7500
|
+
import_react_native14.Animated.timing(opacity, { toValue: 0.5, duration: 700, useNativeDriver: true }),
|
|
7501
|
+
import_react_native14.Animated.timing(opacity, { toValue: 1, duration: 700, useNativeDriver: true })
|
|
7502
|
+
])
|
|
7503
|
+
);
|
|
7504
|
+
breathe.start();
|
|
7505
|
+
return () => breathe.stop();
|
|
7506
|
+
}, [opacity]);
|
|
7507
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
7508
|
+
import_react_native14.Animated.View,
|
|
7509
|
+
{
|
|
7510
|
+
style: [{ backgroundColor: colors.skeleton, opacity }, style],
|
|
7511
|
+
accessibilityElementsHidden: true,
|
|
7512
|
+
importantForAccessibility: "no-hide-descendants"
|
|
7513
|
+
}
|
|
7514
|
+
);
|
|
7515
|
+
}
|
|
7516
|
+
|
|
7046
7517
|
// src/components/MessageFiles.tsx
|
|
7047
|
-
var
|
|
7048
|
-
var IMAGE_SIDE = 224;
|
|
7518
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
7049
7519
|
function MessageFiles({ attachments, own, stored }) {
|
|
7050
|
-
const { chat: chat2, t, colors,
|
|
7520
|
+
const { chat: chat2, t, colors, openImages } = useChatContext();
|
|
7051
7521
|
const links = useAttachmentLinks(
|
|
7052
7522
|
chat2,
|
|
7053
7523
|
attachments.map((attachment) => attachment.key),
|
|
7054
7524
|
stored
|
|
7055
7525
|
);
|
|
7056
7526
|
if (attachments.length === 0) return null;
|
|
7057
|
-
|
|
7527
|
+
const gallery = attachments.flatMap((attachment) => {
|
|
7528
|
+
const url = links.get(attachment.key);
|
|
7529
|
+
return url && isImage(attachment.type) ? [{ url, name: attachment.name }] : [];
|
|
7530
|
+
});
|
|
7531
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native15.View, { style: [styles9.files, { alignItems: own ? "flex-end" : "flex-start" }], children: attachments.map((attachment) => {
|
|
7058
7532
|
const url = links.get(attachment.key);
|
|
7059
7533
|
if (isImage(attachment.type)) {
|
|
7060
7534
|
const size = imageSize(attachment);
|
|
7061
|
-
return url ? /* @__PURE__ */ (0,
|
|
7062
|
-
|
|
7535
|
+
return url ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
7536
|
+
import_react_native15.Pressable,
|
|
7063
7537
|
{
|
|
7064
|
-
onPress: () =>
|
|
7538
|
+
onPress: () => openImages({ images: gallery, index: gallery.findIndex((image) => image.url === url) }),
|
|
7065
7539
|
accessibilityRole: "imagebutton",
|
|
7066
7540
|
accessibilityLabel: t.open_image,
|
|
7067
|
-
style: [
|
|
7068
|
-
children: /* @__PURE__ */ (0,
|
|
7069
|
-
},
|
|
7070
|
-
attachment.key
|
|
7071
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
7072
|
-
import_react_native12.View,
|
|
7073
|
-
{
|
|
7074
|
-
style: [styles8.image, size, { backgroundColor: colors.surface, borderColor: colors.border }]
|
|
7541
|
+
style: ({ pressed }) => [styles9.image, { borderColor: colors.border }, pressed && styles9.pressed],
|
|
7542
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native15.Image, { source: { uri: url }, style: size, resizeMode: "cover", accessibilityLabel: attachment.name })
|
|
7075
7543
|
},
|
|
7076
7544
|
attachment.key
|
|
7077
|
-
);
|
|
7545
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Skeleton, { style: [styles9.image, size, { borderColor: colors.border }] }, attachment.key);
|
|
7078
7546
|
}
|
|
7079
|
-
return /* @__PURE__ */ (0,
|
|
7080
|
-
|
|
7547
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
7548
|
+
import_react_native15.Pressable,
|
|
7081
7549
|
{
|
|
7082
7550
|
disabled: !url,
|
|
7083
|
-
onPress: () =>
|
|
7551
|
+
onPress: () => void import_react_native15.Linking.openURL(withFileName(url, attachment.name)),
|
|
7084
7552
|
accessibilityRole: "link",
|
|
7085
7553
|
accessibilityLabel: format(t.open_file, { name: attachment.name }),
|
|
7086
|
-
style:
|
|
7554
|
+
style: ({ pressed }) => [
|
|
7555
|
+
styles9.file,
|
|
7556
|
+
{ borderColor: colors.border, backgroundColor: colors.surface },
|
|
7557
|
+
pressed && styles9.pressed
|
|
7558
|
+
],
|
|
7087
7559
|
children: [
|
|
7088
|
-
/* @__PURE__ */ (0,
|
|
7089
|
-
/* @__PURE__ */ (0,
|
|
7090
|
-
/* @__PURE__ */ (0,
|
|
7560
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native15.View, { style: [styles9.fileIcon, { backgroundColor: colors.primaryTint }], children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Icon, { name: "file", color: colors.primaryText, size: 16 }) }),
|
|
7561
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_native15.Text, { style: [styles9.fileName, { color: colors.text }], numberOfLines: 1, children: attachment.name }),
|
|
7562
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Icon, { name: "download", color: colors.muted, size: 16 })
|
|
7091
7563
|
]
|
|
7092
7564
|
},
|
|
7093
7565
|
attachment.key
|
|
@@ -7095,318 +7567,456 @@ function MessageFiles({ attachments, own, stored }) {
|
|
|
7095
7567
|
}) });
|
|
7096
7568
|
}
|
|
7097
7569
|
function imageSize({ width, height }) {
|
|
7098
|
-
if (!width || !height) return { width:
|
|
7570
|
+
if (!width || !height) return { width: 180, height: 180 };
|
|
7099
7571
|
const scale = IMAGE_SIDE / Math.max(width, height);
|
|
7100
|
-
return { width: Math.max(
|
|
7572
|
+
return { width: Math.max(96, Math.round(width * scale)), height: Math.max(96, Math.round(height * scale)) };
|
|
7101
7573
|
}
|
|
7102
|
-
var
|
|
7103
|
-
files: { gap:
|
|
7104
|
-
image: { overflow: "hidden", borderRadius:
|
|
7574
|
+
var styles9 = import_react_native15.StyleSheet.create({
|
|
7575
|
+
files: { gap: 4 },
|
|
7576
|
+
image: { overflow: "hidden", borderRadius: RADII.group, borderWidth: 1 },
|
|
7577
|
+
pressed: { opacity: 0.8 },
|
|
7105
7578
|
file: {
|
|
7106
7579
|
flexDirection: "row",
|
|
7107
7580
|
alignItems: "center",
|
|
7108
7581
|
gap: 10,
|
|
7109
|
-
width:
|
|
7110
|
-
padding:
|
|
7111
|
-
borderRadius:
|
|
7112
|
-
borderWidth:
|
|
7582
|
+
width: 232,
|
|
7583
|
+
padding: 10,
|
|
7584
|
+
borderRadius: RADII.group,
|
|
7585
|
+
borderWidth: 1
|
|
7113
7586
|
},
|
|
7114
|
-
|
|
7587
|
+
fileIcon: { width: 32, height: 32, borderRadius: 16, alignItems: "center", justifyContent: "center" },
|
|
7588
|
+
fileName: { flex: 1, fontSize: 14, fontWeight: "500" }
|
|
7589
|
+
});
|
|
7590
|
+
|
|
7591
|
+
// src/components/MessageMeta.tsx
|
|
7592
|
+
var import_react_native16 = require("react-native");
|
|
7593
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
7594
|
+
function MessageMeta({ row, onRetry }) {
|
|
7595
|
+
const { t, locale, colors } = useChatContext();
|
|
7596
|
+
const { message, receipt } = row;
|
|
7597
|
+
if (message.status === "failed") {
|
|
7598
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_react_native16.View, { style: [styles10.meta, styles10.own], accessibilityLiveRegion: "polite", children: [
|
|
7599
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native16.Text, { style: [styles10.text, { color: colors.danger }], children: message.error === "rate_limited" ? t.rate_limited : t.not_sent }),
|
|
7600
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native16.Pressable, { onPress: onRetry, accessibilityRole: "button", hitSlop: 8, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native16.Text, { style: [styles10.text, styles10.retry, { color: colors.danger }], children: t.retry }) })
|
|
7601
|
+
] });
|
|
7602
|
+
}
|
|
7603
|
+
if (receipt === "sending") {
|
|
7604
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native16.View, { style: [styles10.meta, styles10.own], children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native16.Text, { style: [styles10.text, { color: colors.muted }], children: t.sending }) });
|
|
7605
|
+
}
|
|
7606
|
+
const time = messageTime(message.createdAt, locale);
|
|
7607
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
7608
|
+
import_react_native16.View,
|
|
7609
|
+
{
|
|
7610
|
+
style: [styles10.meta, receipt ? styles10.own : styles10.team],
|
|
7611
|
+
accessible: true,
|
|
7612
|
+
accessibilityLabel: receipt ? `${time}, ${receipt === "seen" ? t.seen : t.sent}` : time,
|
|
7613
|
+
children: [
|
|
7614
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native16.Text, { style: [styles10.text, { color: colors.muted }], children: time }),
|
|
7615
|
+
receipt && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
7616
|
+
Icon,
|
|
7617
|
+
{
|
|
7618
|
+
name: receipt === "seen" ? "seen" : "check",
|
|
7619
|
+
color: receipt === "seen" ? colors.primaryText : colors.muted,
|
|
7620
|
+
size: 14
|
|
7621
|
+
}
|
|
7622
|
+
)
|
|
7623
|
+
]
|
|
7624
|
+
}
|
|
7625
|
+
);
|
|
7626
|
+
}
|
|
7627
|
+
var styles10 = import_react_native16.StyleSheet.create({
|
|
7628
|
+
meta: { flexDirection: "row", flexWrap: "wrap", alignItems: "center", gap: 4, marginTop: 4, paddingHorizontal: 4 },
|
|
7629
|
+
own: { alignSelf: "flex-end", justifyContent: "flex-end" },
|
|
7630
|
+
team: { alignSelf: "flex-start" },
|
|
7631
|
+
text: { fontSize: 12 },
|
|
7632
|
+
retry: { fontWeight: "600", textDecorationLine: "underline" }
|
|
7115
7633
|
});
|
|
7116
7634
|
|
|
7117
7635
|
// src/components/TeamAvatar.tsx
|
|
7118
|
-
var
|
|
7119
|
-
var
|
|
7636
|
+
var import_react_native17 = require("react-native");
|
|
7637
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
7120
7638
|
function TeamAvatar({ app, sender }) {
|
|
7121
7639
|
const { colors } = useChatContext();
|
|
7122
7640
|
const image = sender ? sender.image : app.logoUrl;
|
|
7123
|
-
if (image)
|
|
7124
|
-
|
|
7125
|
-
|
|
7641
|
+
if (image) {
|
|
7642
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native17.Image, { source: { uri: image }, style: [styles11.avatar, { borderColor: colors.border }], accessibilityIgnoresInvertColors: true });
|
|
7643
|
+
}
|
|
7644
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
7645
|
+
import_react_native17.View,
|
|
7126
7646
|
{
|
|
7127
|
-
style: [
|
|
7647
|
+
style: [styles11.avatar, { backgroundColor: sender ? colors.primaryTint : colors.primary }],
|
|
7128
7648
|
accessibilityElementsHidden: true,
|
|
7129
7649
|
importantForAccessibility: "no-hide-descendants",
|
|
7130
|
-
children: /* @__PURE__ */ (0,
|
|
7650
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native17.Text, { style: [styles11.initials, { color: sender ? colors.primaryText : colors.primaryForeground }], children: initialsOf(sender?.name ?? app.name) })
|
|
7131
7651
|
}
|
|
7132
7652
|
);
|
|
7133
7653
|
}
|
|
7134
|
-
var
|
|
7135
|
-
avatar: {
|
|
7136
|
-
|
|
7654
|
+
var styles11 = import_react_native17.StyleSheet.create({
|
|
7655
|
+
avatar: {
|
|
7656
|
+
width: 28,
|
|
7657
|
+
height: 28,
|
|
7658
|
+
borderRadius: 14,
|
|
7659
|
+
borderWidth: 1,
|
|
7660
|
+
borderColor: "transparent",
|
|
7661
|
+
alignItems: "center",
|
|
7662
|
+
justifyContent: "center",
|
|
7663
|
+
overflow: "hidden"
|
|
7664
|
+
},
|
|
7665
|
+
initials: { fontSize: 11, fontWeight: "700" }
|
|
7137
7666
|
});
|
|
7138
7667
|
|
|
7139
7668
|
// src/components/MessageBubble.tsx
|
|
7140
|
-
var
|
|
7141
|
-
function MessageBubble({
|
|
7142
|
-
const { t, colors } = useChatContext();
|
|
7143
|
-
|
|
7144
|
-
|
|
7145
|
-
|
|
7146
|
-
|
|
7669
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
7670
|
+
function MessageBubble({ row, app, onRetry }) {
|
|
7671
|
+
const { t, locale, colors, openedAt } = useChatContext();
|
|
7672
|
+
const { message, startsRun, endsRun, startsDay } = row;
|
|
7673
|
+
const own = message.from === "contact";
|
|
7674
|
+
const rise = useRiseIn(message.createdAt > openedAt && (!own || message.status === "sending"));
|
|
7675
|
+
const corner = startsRun ? RADII.group : RADII.inner;
|
|
7676
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_react_native18.Animated.View, { style: [styles12.row, { paddingTop: startsRun ? 14 : 3 }, rise], children: [
|
|
7677
|
+
startsDay && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native18.Text, { style: [styles12.day, { backgroundColor: colors.surface, color: colors.muted }], accessibilityRole: "header", children: dayLabel(message.createdAt, openedAt, locale, t) }),
|
|
7678
|
+
own ? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_react_native18.View, { style: styles12.own, children: [
|
|
7679
|
+
message.body !== "" && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
7680
|
+
import_react_native18.Text,
|
|
7147
7681
|
{
|
|
7148
7682
|
selectable: true,
|
|
7149
7683
|
style: [
|
|
7150
|
-
|
|
7151
|
-
|
|
7152
|
-
{ backgroundColor: colors.primary, color: colors.primaryForeground }
|
|
7153
|
-
message.status === "sending" && styles10.sending
|
|
7684
|
+
styles12.bubble,
|
|
7685
|
+
{ borderTopRightRadius: corner, borderBottomRightRadius: RADII.inner },
|
|
7686
|
+
{ backgroundColor: colors.primary, color: colors.primaryForeground }
|
|
7154
7687
|
],
|
|
7155
7688
|
children: message.body
|
|
7156
7689
|
}
|
|
7157
7690
|
),
|
|
7158
|
-
/* @__PURE__ */ (0,
|
|
7159
|
-
|
|
7160
|
-
|
|
7161
|
-
|
|
7162
|
-
|
|
7163
|
-
|
|
7164
|
-
|
|
7165
|
-
|
|
7166
|
-
|
|
7167
|
-
|
|
7168
|
-
|
|
7169
|
-
|
|
7170
|
-
|
|
7691
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(MessageFiles, { attachments: message.attachments, own: true, stored: message.status === "sent" }),
|
|
7692
|
+
endsRun && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(MessageMeta, { row, onRetry })
|
|
7693
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_react_native18.View, { style: styles12.team, children: [
|
|
7694
|
+
startsRun && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native18.Text, { style: [styles12.name, { color: colors.muted }], numberOfLines: 1, children: message.sender?.name ?? app.name }),
|
|
7695
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_react_native18.View, { style: styles12.teamRow, children: [
|
|
7696
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native18.View, { style: styles12.avatar, children: endsRun && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(TeamAvatar, { app, sender: message.sender }) }),
|
|
7697
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_react_native18.View, { style: styles12.teamColumn, children: [
|
|
7698
|
+
message.body !== "" && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
7699
|
+
import_react_native18.Text,
|
|
7700
|
+
{
|
|
7701
|
+
selectable: true,
|
|
7702
|
+
style: [
|
|
7703
|
+
styles12.bubble,
|
|
7704
|
+
{ borderTopLeftRadius: corner, borderBottomLeftRadius: RADII.inner },
|
|
7705
|
+
{ backgroundColor: colors.surface, color: colors.text }
|
|
7706
|
+
],
|
|
7707
|
+
children: message.body
|
|
7708
|
+
}
|
|
7709
|
+
),
|
|
7710
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(MessageFiles, { attachments: message.attachments, own: false, stored: true })
|
|
7711
|
+
] })
|
|
7712
|
+
] }),
|
|
7713
|
+
endsRun && !row.welcome && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native18.View, { style: styles12.teamMeta, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(MessageMeta, { row, onRetry }) })
|
|
7171
7714
|
] })
|
|
7172
7715
|
] });
|
|
7173
7716
|
}
|
|
7174
|
-
var
|
|
7717
|
+
var AVATAR = 28;
|
|
7718
|
+
var styles12 = import_react_native18.StyleSheet.create({
|
|
7719
|
+
row: { paddingHorizontal: 12 },
|
|
7720
|
+
day: {
|
|
7721
|
+
alignSelf: "center",
|
|
7722
|
+
marginBottom: 14,
|
|
7723
|
+
paddingHorizontal: 12,
|
|
7724
|
+
paddingVertical: 4,
|
|
7725
|
+
borderRadius: RADII.pill,
|
|
7726
|
+
overflow: "hidden",
|
|
7727
|
+
fontSize: 12,
|
|
7728
|
+
fontWeight: "700",
|
|
7729
|
+
letterSpacing: 1,
|
|
7730
|
+
textTransform: "uppercase"
|
|
7731
|
+
},
|
|
7175
7732
|
own: { alignSelf: "flex-end", alignItems: "flex-end", maxWidth: "80%", gap: 4 },
|
|
7176
|
-
team: {
|
|
7177
|
-
|
|
7178
|
-
|
|
7179
|
-
|
|
7180
|
-
|
|
7181
|
-
|
|
7182
|
-
|
|
7183
|
-
|
|
7184
|
-
|
|
7185
|
-
|
|
7733
|
+
team: { alignSelf: "flex-start", maxWidth: "85%" },
|
|
7734
|
+
name: { marginBottom: 4, marginLeft: AVATAR + 12, fontSize: 12, fontWeight: "600" },
|
|
7735
|
+
teamRow: { flexDirection: "row", alignItems: "flex-end", gap: 8 },
|
|
7736
|
+
avatar: { width: AVATAR },
|
|
7737
|
+
teamColumn: { flexShrink: 1, alignItems: "flex-start", gap: 4 },
|
|
7738
|
+
teamMeta: { marginLeft: AVATAR + 8 },
|
|
7739
|
+
bubble: {
|
|
7740
|
+
borderRadius: RADII.group,
|
|
7741
|
+
paddingHorizontal: 14,
|
|
7742
|
+
paddingVertical: 10,
|
|
7743
|
+
fontSize: 16,
|
|
7744
|
+
lineHeight: 22,
|
|
7745
|
+
overflow: "hidden"
|
|
7746
|
+
}
|
|
7186
7747
|
});
|
|
7187
7748
|
|
|
7188
7749
|
// src/components/TypingBubble.tsx
|
|
7189
|
-
var
|
|
7190
|
-
var
|
|
7191
|
-
var
|
|
7750
|
+
var import_react13 = require("react");
|
|
7751
|
+
var import_react_native19 = require("react-native");
|
|
7752
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
7192
7753
|
function TypingBubble({ app, sender }) {
|
|
7193
7754
|
const { t, colors } = useChatContext();
|
|
7194
|
-
const
|
|
7195
|
-
(0,
|
|
7196
|
-
|
|
7197
|
-
|
|
7755
|
+
const rise = useRiseIn(true);
|
|
7756
|
+
const dots = (0, import_react13.useRef)([0, 1, 2].map(() => new import_react_native19.Animated.Value(0))).current;
|
|
7757
|
+
(0, import_react13.useEffect)(() => {
|
|
7758
|
+
const bounce = import_react_native19.Animated.loop(
|
|
7759
|
+
import_react_native19.Animated.stagger(
|
|
7198
7760
|
150,
|
|
7199
7761
|
dots.map(
|
|
7200
|
-
(dot) =>
|
|
7201
|
-
|
|
7202
|
-
|
|
7203
|
-
|
|
7762
|
+
(dot) => import_react_native19.Animated.sequence([
|
|
7763
|
+
import_react_native19.Animated.timing(dot, { toValue: 1, duration: 300, useNativeDriver: true }),
|
|
7764
|
+
import_react_native19.Animated.timing(dot, { toValue: 0, duration: 300, useNativeDriver: true }),
|
|
7765
|
+
import_react_native19.Animated.delay(300)
|
|
7204
7766
|
])
|
|
7205
7767
|
)
|
|
7206
7768
|
)
|
|
7207
7769
|
);
|
|
7208
|
-
|
|
7209
|
-
return () =>
|
|
7770
|
+
bounce.start();
|
|
7771
|
+
return () => bounce.stop();
|
|
7210
7772
|
}, [dots]);
|
|
7211
|
-
return /* @__PURE__ */ (0,
|
|
7212
|
-
/* @__PURE__ */ (0,
|
|
7213
|
-
/* @__PURE__ */ (0,
|
|
7773
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_react_native19.Animated.View, { style: [styles13.row, rise], accessible: true, accessibilityLabel: format(t.typing, { name: sender?.name ?? t.team }), children: [
|
|
7774
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(TeamAvatar, { app, sender }),
|
|
7775
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react_native19.View, { style: [styles13.bubble, { backgroundColor: colors.surface }], children: dots.map((dot, index) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
7776
|
+
import_react_native19.Animated.View,
|
|
7777
|
+
{
|
|
7778
|
+
style: [
|
|
7779
|
+
styles13.dot,
|
|
7780
|
+
{
|
|
7781
|
+
backgroundColor: colors.muted,
|
|
7782
|
+
opacity: dot.interpolate({ inputRange: [0, 1], outputRange: [0.35, 1] }),
|
|
7783
|
+
transform: [{ translateY: dot.interpolate({ inputRange: [0, 1], outputRange: [0, -3] }) }]
|
|
7784
|
+
}
|
|
7785
|
+
]
|
|
7786
|
+
},
|
|
7787
|
+
index
|
|
7788
|
+
)) })
|
|
7214
7789
|
] });
|
|
7215
7790
|
}
|
|
7216
|
-
var
|
|
7217
|
-
row: { flexDirection: "row", alignItems: "
|
|
7791
|
+
var styles13 = import_react_native19.StyleSheet.create({
|
|
7792
|
+
row: { flexDirection: "row", alignItems: "flex-end", gap: 8, paddingHorizontal: 12, paddingTop: 14 },
|
|
7218
7793
|
bubble: {
|
|
7219
7794
|
flexDirection: "row",
|
|
7220
7795
|
alignItems: "center",
|
|
7221
|
-
gap:
|
|
7222
|
-
height:
|
|
7223
|
-
paddingHorizontal:
|
|
7224
|
-
borderRadius:
|
|
7225
|
-
|
|
7796
|
+
gap: 5,
|
|
7797
|
+
height: 42,
|
|
7798
|
+
paddingHorizontal: 16,
|
|
7799
|
+
borderRadius: RADII.group,
|
|
7800
|
+
borderBottomLeftRadius: RADII.inner
|
|
7226
7801
|
},
|
|
7227
|
-
dot: { width:
|
|
7802
|
+
dot: { width: 7, height: 7, borderRadius: 3.5 }
|
|
7228
7803
|
});
|
|
7229
7804
|
|
|
7230
7805
|
// src/components/MessageList.tsx
|
|
7231
|
-
var
|
|
7806
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
7232
7807
|
function MessageList({ state }) {
|
|
7233
|
-
const { chat: chat2, t, colors } = useChatContext();
|
|
7808
|
+
const { chat: chat2, t, colors, openedAt } = useChatContext();
|
|
7809
|
+
const listRef = (0, import_react14.useRef)(null);
|
|
7810
|
+
const [scrolledUp, setScrolledUp] = (0, import_react14.useState)(false);
|
|
7234
7811
|
const app = state.app;
|
|
7235
|
-
const { messages } = state;
|
|
7236
|
-
const
|
|
7237
|
-
const
|
|
7238
|
-
|
|
7239
|
-
|
|
7240
|
-
|
|
7241
|
-
|
|
7242
|
-
|
|
7243
|
-
|
|
7244
|
-
|
|
7245
|
-
|
|
7246
|
-
|
|
7247
|
-
|
|
7248
|
-
|
|
7249
|
-
|
|
7250
|
-
|
|
7251
|
-
|
|
7252
|
-
|
|
7253
|
-
{
|
|
7254
|
-
|
|
7255
|
-
|
|
7256
|
-
|
|
7257
|
-
|
|
7258
|
-
|
|
7259
|
-
|
|
7260
|
-
|
|
7261
|
-
|
|
7262
|
-
|
|
7263
|
-
|
|
7264
|
-
|
|
7265
|
-
|
|
7266
|
-
|
|
7267
|
-
|
|
7268
|
-
}
|
|
7269
|
-
)
|
|
7270
|
-
|
|
7271
|
-
|
|
7272
|
-
ListHeaderComponent: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_react_native16.View, { style: styles12.below, children: [
|
|
7273
|
-
state.teamTyping && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(TypingBubble, { app, sender: state.teamTyping.sender }),
|
|
7274
|
-
askEmail && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(EmailForm, { onSubmit: chat2.setEmail }),
|
|
7275
|
-
state.email && !state.online && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native16.Text, { style: [styles12.saved, { color: colors.muted }], children: format(t.email_saved, { email: state.email }) })
|
|
7276
|
-
] }),
|
|
7277
|
-
ListFooterComponent: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_react_native16.View, { style: styles12.above, children: [
|
|
7278
|
-
state.hasOlder && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
7279
|
-
import_react_native16.Pressable,
|
|
7812
|
+
const { messages, seen, atStart } = state;
|
|
7813
|
+
const welcomeText = state.texts.welcome;
|
|
7814
|
+
const rows = (0, import_react14.useMemo)(() => {
|
|
7815
|
+
const welcome = atStart ? {
|
|
7816
|
+
id: "welcome",
|
|
7817
|
+
from: "team",
|
|
7818
|
+
sender: null,
|
|
7819
|
+
body: welcomeText,
|
|
7820
|
+
attachments: [],
|
|
7821
|
+
createdAt: messages[0]?.createdAt ?? openedAt,
|
|
7822
|
+
status: "sent",
|
|
7823
|
+
error: null
|
|
7824
|
+
} : null;
|
|
7825
|
+
return conversationRows(messages, seen, welcome).reverse();
|
|
7826
|
+
}, [messages, seen, atStart, welcomeText, openedAt]);
|
|
7827
|
+
const newest = rows.at(0)?.message;
|
|
7828
|
+
const sending = newest?.from === "contact" && newest.status === "sending" ? newest.id : null;
|
|
7829
|
+
(0, import_react14.useEffect)(() => {
|
|
7830
|
+
if (sending) listRef.current?.scrollToOffset({ offset: 0, animated: true });
|
|
7831
|
+
}, [sending]);
|
|
7832
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_react_native20.View, { style: styles14.list, children: [
|
|
7833
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
7834
|
+
import_react_native20.FlatList,
|
|
7835
|
+
{
|
|
7836
|
+
ref: listRef,
|
|
7837
|
+
testID: "zean-conversation",
|
|
7838
|
+
inverted: true,
|
|
7839
|
+
data: rows,
|
|
7840
|
+
keyExtractor: (row) => row.message.id,
|
|
7841
|
+
renderItem: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(MessageBubble, { row: item, app, onRetry: () => chat2.retry(item.message.id) }),
|
|
7842
|
+
ListHeaderComponent: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_react_native20.View, { style: styles14.below, children: [
|
|
7843
|
+
state.teamTyping && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(TypingBubble, { app, sender: state.teamTyping.sender }),
|
|
7844
|
+
state.askEmail && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(EmailForm, { onSubmit: chat2.setEmail }),
|
|
7845
|
+
state.email && (!state.online || state.emailGiven) && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react_native20.Text, { style: [styles14.saved, { color: colors.muted }], children: format(t.email_saved, { email: state.email }) })
|
|
7846
|
+
] }),
|
|
7847
|
+
ListFooterComponent: state.hasOlder ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react_native20.View, { style: styles14.above, children: state.loadingOlder ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Skeleton, { style: [styles14.bone, styles14.olderBone] }) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
7848
|
+
import_react_native20.Pressable,
|
|
7280
7849
|
{
|
|
7281
7850
|
onPress: chat2.loadOlder,
|
|
7282
|
-
disabled: state.loadingOlder,
|
|
7283
7851
|
accessibilityRole: "button",
|
|
7284
|
-
style: [
|
|
7285
|
-
children: /* @__PURE__ */ (0,
|
|
7852
|
+
style: ({ pressed }) => [styles14.earlier, { backgroundColor: colors.surface }, pressed && styles14.pressed],
|
|
7853
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react_native20.Text, { style: [styles14.earlierText, { color: colors.muted }], children: t.earlier })
|
|
7286
7854
|
}
|
|
7287
|
-
),
|
|
7288
|
-
|
|
7289
|
-
|
|
7290
|
-
|
|
7291
|
-
|
|
7292
|
-
|
|
7293
|
-
|
|
7294
|
-
|
|
7295
|
-
|
|
7296
|
-
|
|
7297
|
-
|
|
7298
|
-
|
|
7299
|
-
|
|
7855
|
+
) }) : void 0,
|
|
7856
|
+
onScroll: (event) => setScrolledUp(event.nativeEvent.contentOffset.y > NEWEST_BUTTON_OFFSET),
|
|
7857
|
+
scrollEventThrottle: 64,
|
|
7858
|
+
maintainVisibleContentPosition: scrolledUp ? { minIndexForVisible: 0 } : void 0,
|
|
7859
|
+
contentContainerStyle: styles14.content,
|
|
7860
|
+
keyboardShouldPersistTaps: "handled",
|
|
7861
|
+
keyboardDismissMode: "on-drag",
|
|
7862
|
+
style: styles14.list
|
|
7863
|
+
}
|
|
7864
|
+
),
|
|
7865
|
+
scrolledUp && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
7866
|
+
import_react_native20.Pressable,
|
|
7867
|
+
{
|
|
7868
|
+
onPress: () => listRef.current?.scrollToOffset({ offset: 0, animated: true }),
|
|
7869
|
+
accessibilityRole: "button",
|
|
7870
|
+
accessibilityLabel: t.newest,
|
|
7871
|
+
style: ({ pressed }) => [
|
|
7872
|
+
styles14.newest,
|
|
7873
|
+
{ backgroundColor: colors.surface, borderColor: colors.border },
|
|
7874
|
+
pressed && styles14.pressed
|
|
7875
|
+
],
|
|
7876
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Icon, { name: "down", color: colors.text, size: 20 })
|
|
7877
|
+
}
|
|
7878
|
+
)
|
|
7879
|
+
] });
|
|
7300
7880
|
}
|
|
7301
|
-
var
|
|
7881
|
+
var styles14 = import_react_native20.StyleSheet.create({
|
|
7302
7882
|
list: { flex: 1 },
|
|
7303
7883
|
// Inverted, `flex-end` is the top: a short Conversation starts under the header, as in the web widget.
|
|
7304
|
-
content: { flexGrow: 1, justifyContent: "flex-end",
|
|
7305
|
-
|
|
7306
|
-
|
|
7307
|
-
|
|
7308
|
-
|
|
7309
|
-
|
|
7310
|
-
|
|
7311
|
-
|
|
7884
|
+
content: { flexGrow: 1, justifyContent: "flex-end", paddingBottom: 12, paddingTop: 4 },
|
|
7885
|
+
below: { gap: 10 },
|
|
7886
|
+
above: { alignItems: "center", paddingTop: 8 },
|
|
7887
|
+
saved: { paddingTop: 10, paddingHorizontal: 16, fontSize: 12, textAlign: "center" },
|
|
7888
|
+
earlier: { paddingHorizontal: 14, paddingVertical: 6, borderRadius: RADII.pill },
|
|
7889
|
+
earlierText: { fontSize: 12, fontWeight: "600" },
|
|
7890
|
+
pressed: { opacity: 0.6 },
|
|
7891
|
+
bone: { height: 44, borderRadius: RADII.group },
|
|
7892
|
+
olderBone: { width: "50%", alignSelf: "flex-start", marginHorizontal: 12 },
|
|
7893
|
+
newest: {
|
|
7894
|
+
position: "absolute",
|
|
7895
|
+
right: 16,
|
|
7896
|
+
bottom: 12,
|
|
7897
|
+
width: COMPOSER_BUTTON,
|
|
7898
|
+
height: COMPOSER_BUTTON,
|
|
7899
|
+
borderRadius: COMPOSER_BUTTON / 2,
|
|
7900
|
+
borderWidth: import_react_native20.StyleSheet.hairlineWidth,
|
|
7901
|
+
alignItems: "center",
|
|
7902
|
+
justifyContent: "center",
|
|
7903
|
+
shadowColor: "#000000",
|
|
7904
|
+
shadowOpacity: 0.12,
|
|
7905
|
+
shadowRadius: 8,
|
|
7906
|
+
shadowOffset: { width: 0, height: 2 },
|
|
7907
|
+
elevation: 3
|
|
7908
|
+
}
|
|
7312
7909
|
});
|
|
7313
7910
|
|
|
7314
7911
|
// src/components/PoweredBy.tsx
|
|
7315
|
-
var
|
|
7316
|
-
var
|
|
7912
|
+
var import_react_native21 = require("react-native");
|
|
7913
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
7317
7914
|
function PoweredBy() {
|
|
7318
7915
|
const { t, colors } = useChatContext();
|
|
7319
|
-
return /* @__PURE__ */ (0,
|
|
7320
|
-
|
|
7321
|
-
|
|
7322
|
-
|
|
7323
|
-
|
|
7916
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
7917
|
+
import_react_native21.Pressable,
|
|
7918
|
+
{
|
|
7919
|
+
style: ({ pressed }) => [styles15.row, pressed && styles15.pressed],
|
|
7920
|
+
accessibilityRole: "link",
|
|
7921
|
+
accessibilityLabel: `${t.powered_by} ${APP_NAME}`,
|
|
7922
|
+
onPress: () => void import_react_native21.Linking.openURL(APP_URL),
|
|
7923
|
+
children: [
|
|
7924
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_native21.Text, { style: [styles15.text, { color: colors.muted }], children: t.powered_by }),
|
|
7925
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Icon, { name: "mark", color: ZEAN_ACCENT_HEX, size: 14 }),
|
|
7926
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_native21.Text, { style: [styles15.text, styles15.name, { color: colors.muted }], children: APP_NAME })
|
|
7927
|
+
]
|
|
7928
|
+
}
|
|
7929
|
+
);
|
|
7324
7930
|
}
|
|
7325
|
-
var
|
|
7326
|
-
row: { flexDirection: "row", alignItems: "center", justifyContent: "center", gap: 4 },
|
|
7931
|
+
var styles15 = import_react_native21.StyleSheet.create({
|
|
7932
|
+
row: { flexDirection: "row", alignItems: "center", justifyContent: "center", alignSelf: "center", gap: 4 },
|
|
7933
|
+
pressed: { opacity: 0.6 },
|
|
7327
7934
|
text: { fontSize: 12 },
|
|
7328
7935
|
name: { fontWeight: "600" }
|
|
7329
7936
|
});
|
|
7330
7937
|
|
|
7331
7938
|
// src/components/ChatScreen.tsx
|
|
7332
|
-
var
|
|
7939
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
7333
7940
|
function ChatScreen({ state, insets, onClose }) {
|
|
7334
7941
|
const { t, colors } = useChatContext();
|
|
7335
|
-
const rootRef = (0,
|
|
7942
|
+
const rootRef = (0, import_react15.useRef)(null);
|
|
7336
7943
|
const keyboard = useKeyboardOverlap(rootRef);
|
|
7337
7944
|
const connectionLost = useConnectionLost(state.connected);
|
|
7338
|
-
const [codeDismissed, setCodeDismissed] = (0,
|
|
7945
|
+
const [codeDismissed, setCodeDismissed] = (0, import_react15.useState)(false);
|
|
7339
7946
|
const app = state.app;
|
|
7340
|
-
return /* @__PURE__ */ (0,
|
|
7341
|
-
/* @__PURE__ */ (0,
|
|
7342
|
-
|
|
7343
|
-
|
|
7344
|
-
|
|
7345
|
-
|
|
7346
|
-
|
|
7347
|
-
|
|
7348
|
-
onClose
|
|
7349
|
-
}
|
|
7350
|
-
),
|
|
7351
|
-
connectionLost && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react_native18.View, { style: styles14.notice, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ChatNotice, { children: t.reconnecting }) }),
|
|
7352
|
-
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(MessageList, { state }),
|
|
7353
|
-
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_react_native18.View, { style: [styles14.footer, { borderTopColor: colors.border, paddingBottom: 8 + (keyboard > 0 ? 0 : insets.bottom) }], children: [
|
|
7354
|
-
state.contactCode && !codeDismissed && state.status === "ready" && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ContactCodeCard, { code: state.contactCode, onDismiss: () => setCodeDismissed(true) }),
|
|
7355
|
-
state.status === "blocked" ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ChatNotice, { children: t.blocked }) : state.status === "unavailable" ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ChatNotice, { children: t.unavailable }) : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Composer, {}),
|
|
7356
|
-
app.showBadge && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(PoweredBy, {})
|
|
7947
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_react_native22.View, { ref: rootRef, style: [styles16.screen, { backgroundColor: colors.background, paddingBottom: keyboard }], children: [
|
|
7948
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ChatHeader, { app, online: state.online, topInset: insets.top, onClose }),
|
|
7949
|
+
connectionLost && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react_native22.View, { style: styles16.notice, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ChatNotice, { children: t.reconnecting }) }),
|
|
7950
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(MessageList, { state }),
|
|
7951
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_react_native22.View, { style: [styles16.footer, { paddingBottom: 8 + (keyboard > 0 ? 0 : insets.bottom) }], children: [
|
|
7952
|
+
state.contactCode && !codeDismissed && state.status === "ready" && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ContactCodeCard, { code: state.contactCode, onDismiss: () => setCodeDismissed(true) }),
|
|
7953
|
+
state.status === "blocked" ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ChatNotice, { children: t.blocked }) : state.status === "unavailable" ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ChatNotice, { children: t.unavailable }) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Composer, {}),
|
|
7954
|
+
app.showBadge && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(PoweredBy, {})
|
|
7357
7955
|
] })
|
|
7358
7956
|
] });
|
|
7359
7957
|
}
|
|
7360
|
-
var
|
|
7958
|
+
var styles16 = import_react_native22.StyleSheet.create({
|
|
7361
7959
|
screen: { flex: 1 },
|
|
7362
|
-
notice: { paddingHorizontal:
|
|
7363
|
-
footer: { gap: 8, paddingHorizontal:
|
|
7960
|
+
notice: { paddingHorizontal: 12, paddingTop: 12 },
|
|
7961
|
+
footer: { gap: 8, paddingHorizontal: 10, paddingTop: 6 }
|
|
7364
7962
|
});
|
|
7365
7963
|
|
|
7366
7964
|
// src/components/ChatModal.tsx
|
|
7367
|
-
var
|
|
7965
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
7368
7966
|
var STRINGS = { fr, en };
|
|
7369
|
-
function ChatModal({ chat: chat2, colorScheme }) {
|
|
7370
|
-
const state = (0,
|
|
7371
|
-
const { open: open2 } = (0,
|
|
7372
|
-
const deviceScheme = (0,
|
|
7967
|
+
function ChatModal({ chat: chat2, colorScheme, maxPhotos }) {
|
|
7968
|
+
const state = (0, import_react16.useSyncExternalStore)(chat2.subscribe, chat2.getState);
|
|
7969
|
+
const { open: open2 } = (0, import_react16.useSyncExternalStore)(subscribeChatView, chatView);
|
|
7970
|
+
const deviceScheme = (0, import_react_native23.useColorScheme)();
|
|
7373
7971
|
const scheme = colorScheme ?? (deviceScheme === "dark" ? "dark" : "light");
|
|
7374
7972
|
const active = useAppActive();
|
|
7375
|
-
const dimensions = (0,
|
|
7376
|
-
const [
|
|
7973
|
+
const dimensions = (0, import_react_native23.useWindowDimensions)();
|
|
7974
|
+
const [gallery, setGallery] = (0, import_react16.useState)(null);
|
|
7975
|
+
const [openedAt, setOpenedAt] = (0, import_react16.useState)(Date.now);
|
|
7377
7976
|
const app = state.app;
|
|
7378
7977
|
const visible = open2 && app !== null && state.status !== "loading" && state.status !== "hidden";
|
|
7379
7978
|
const color = app?.color ?? ZEAN_ACCENT_HEX;
|
|
7380
|
-
const context = (0,
|
|
7381
|
-
() => ({
|
|
7382
|
-
|
|
7979
|
+
const context = (0, import_react16.useMemo)(
|
|
7980
|
+
() => ({
|
|
7981
|
+
chat: chat2,
|
|
7982
|
+
t: STRINGS[state.locale],
|
|
7983
|
+
locale: state.locale,
|
|
7984
|
+
colors: chatColors(color, scheme),
|
|
7985
|
+
openedAt,
|
|
7986
|
+
openImages: setGallery,
|
|
7987
|
+
maxPhotos: photoLimit(maxPhotos)
|
|
7988
|
+
}),
|
|
7989
|
+
[chat2, state.locale, color, scheme, openedAt, maxPhotos]
|
|
7383
7990
|
);
|
|
7384
|
-
const insets = (0,
|
|
7385
|
-
(0,
|
|
7991
|
+
const insets = (0, import_react16.useMemo)(screenInsets, [dimensions.width, dimensions.height]);
|
|
7992
|
+
(0, import_react16.useEffect)(() => chat2.setOpen(open2 && active), [chat2, open2, active]);
|
|
7993
|
+
(0, import_react16.useEffect)(() => {
|
|
7386
7994
|
if (visible && active && state.unread > 0) chat2.markRead();
|
|
7387
7995
|
}, [chat2, visible, active, state.unread]);
|
|
7388
|
-
(0,
|
|
7389
|
-
if (
|
|
7996
|
+
(0, import_react16.useEffect)(() => {
|
|
7997
|
+
if (visible) setOpenedAt(Date.now());
|
|
7998
|
+
else setGallery(null);
|
|
7390
7999
|
}, [visible]);
|
|
7391
|
-
return /* @__PURE__ */ (0,
|
|
7392
|
-
|
|
8000
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
8001
|
+
import_react_native23.Modal,
|
|
7393
8002
|
{
|
|
8003
|
+
testID: "zean-chat",
|
|
7394
8004
|
visible,
|
|
7395
8005
|
animationType: "slide",
|
|
7396
|
-
presentationStyle:
|
|
8006
|
+
presentationStyle: import_react_native23.Platform.OS === "ios" && !import_react_native23.Platform.isPad ? "pageSheet" : "fullScreen",
|
|
7397
8007
|
statusBarTranslucent: true,
|
|
7398
8008
|
navigationBarTranslucent: true,
|
|
7399
|
-
onRequestClose: () =>
|
|
7400
|
-
children: app && /* @__PURE__ */ (0,
|
|
7401
|
-
/* @__PURE__ */ (0,
|
|
7402
|
-
|
|
8009
|
+
onRequestClose: () => import_react_native23.Platform.OS === "android" && gallery ? setGallery(null) : zean.close(),
|
|
8010
|
+
children: app && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(ChatContext, { value: context, children: [
|
|
8011
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ChatScreen, { state, insets, onClose: zean.close }),
|
|
8012
|
+
gallery && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ImageViewer, { gallery, topInset: insets.top, onClose: () => setGallery(null) })
|
|
7403
8013
|
] })
|
|
7404
8014
|
}
|
|
7405
8015
|
);
|
|
7406
8016
|
}
|
|
7407
8017
|
|
|
7408
8018
|
// src/components/ZeanChat.tsx
|
|
7409
|
-
var
|
|
8019
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
7410
8020
|
function ZeanChat({
|
|
7411
8021
|
appKey,
|
|
7412
8022
|
storage,
|
|
@@ -7414,14 +8024,15 @@ function ZeanChat({
|
|
|
7414
8024
|
attributes: attributes2,
|
|
7415
8025
|
locale,
|
|
7416
8026
|
colorScheme,
|
|
8027
|
+
maxPhotos,
|
|
7417
8028
|
backendUrl = backendUrlFor(appKey)
|
|
7418
8029
|
}) {
|
|
7419
|
-
const [chat2, setChat] = (0,
|
|
7420
|
-
const storageRef = (0,
|
|
8030
|
+
const [chat2, setChat] = (0, import_react17.useState)(null);
|
|
8031
|
+
const storageRef = (0, import_react17.useRef)(storage);
|
|
7421
8032
|
const userKey = user ? JSON.stringify(user) : null;
|
|
7422
|
-
const identified = (0,
|
|
8033
|
+
const identified = (0, import_react17.useRef)(false);
|
|
7423
8034
|
const attributesKey = attributes2 ? JSON.stringify(attributes2) : null;
|
|
7424
|
-
(0,
|
|
8035
|
+
(0, import_react17.useEffect)(() => {
|
|
7425
8036
|
const started = createChat({
|
|
7426
8037
|
appKey,
|
|
7427
8038
|
backendUrl,
|
|
@@ -7429,7 +8040,9 @@ function ZeanChat({
|
|
|
7429
8040
|
// A chosen language goes first: the chat takes the first one it speaks.
|
|
7430
8041
|
languages: locale ? [locale] : deviceLanguages(),
|
|
7431
8042
|
deviceLanguage: deviceLanguages()[0],
|
|
7432
|
-
os: deviceOs()
|
|
8043
|
+
os: deviceOs(),
|
|
8044
|
+
// The Conversation stays on the phone: the next start shows it at once and asks only for newer messages.
|
|
8045
|
+
keep: true
|
|
7433
8046
|
});
|
|
7434
8047
|
const detach = attachChat(started);
|
|
7435
8048
|
setChat(started);
|
|
@@ -7438,20 +8051,20 @@ function ZeanChat({
|
|
|
7438
8051
|
started.destroy();
|
|
7439
8052
|
};
|
|
7440
8053
|
}, [appKey, backendUrl, locale]);
|
|
7441
|
-
(0,
|
|
8054
|
+
(0, import_react17.useEffect)(() => {
|
|
7442
8055
|
if (userKey) zean.identify(JSON.parse(userKey));
|
|
7443
8056
|
else if (identified.current) zean.signOut();
|
|
7444
8057
|
identified.current = userKey !== null;
|
|
7445
8058
|
}, [userKey]);
|
|
7446
|
-
(0,
|
|
8059
|
+
(0, import_react17.useEffect)(() => {
|
|
7447
8060
|
if (attributesKey) zean.setAttributes(JSON.parse(attributesKey));
|
|
7448
8061
|
}, [attributesKey]);
|
|
7449
|
-
return chat2 ? /* @__PURE__ */ (0,
|
|
8062
|
+
return chat2 ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ChatModal, { chat: chat2, colorScheme, maxPhotos }) : null;
|
|
7450
8063
|
}
|
|
7451
8064
|
|
|
7452
8065
|
// src/hooks/use-zean.ts
|
|
7453
|
-
var
|
|
8066
|
+
var import_react18 = require("react");
|
|
7454
8067
|
function useZean() {
|
|
7455
|
-
const { unread } = (0,
|
|
8068
|
+
const { unread } = (0, import_react18.useSyncExternalStore)(subscribeChatView, chatView);
|
|
7456
8069
|
return { ...zean, unreadCount: unread };
|
|
7457
8070
|
}
|